Giter Club home page Giter Club logo

ap-cnn_pytorch-master's Introduction

AP-CNN

Code release for Weakly Supervised Attention Pyramid Convolutional Neural Network for Fine-Grained Visual Classification (TIP2021).

Dependencies

Python 3.6 with all of the pip install -r requirements.txt packages including:

  • torch == 0.4.1
  • opencv-python
  • visdom

Data

  1. Download the FGVC image data. Extract them to data/cars/, data/birds/ and data/airs/, respectively.
  -/cars/
     └─── car_ims
             └─── 00001.jpg
             └─── 00002.jpg
             └─── ...
     └─── cars_annos.mat
  -/birds/
     └─── images.txt
     └─── image_class_labels.txt
     └─── train_test_split.txt
     └─── images
             └─── 001.Black_footed_Albatross
                       └─── Black_Footed_Albatross_0001_796111.jpg
                       └─── ...
             └─── 002.Laysan_Albatross
             └─── ...
   -/airs/
     └─── images
             └─── 0034309.jpg
             └─── 0034958.jpg
             └─── ...
     └─── variants.txt
     └─── images_variant_trainval.txt
     └─── images_variant_test.txt
  1. Preprocess images.
  • For birds: python utils/split_dataset/birds_dataset.py
  • For cars: python utils/split_dataset/cars_dataset.py
  • For airs: python utils/split_dataset/airs_dataset.py

Training

Start:

  1. python train.py --dataset {cars,airs,birds} --model {resnet50,vgg19} [options: --visualize] to start training.
  • For example, to train ResNet50 on Stanford-Cars: python train.py --dataset cars --model resnet50
  • Run python train.py --help to see full input arguments.

Visualize:

  1. python -m visdom.server to start visdom server.

  2. Visualize online attention masks and ROIs on http://localhost:8097.

Pretrained Checkpoints

Pretrained checkpoints with following settings are available on download link, with access code "kjqu".

Dataset base model accuracy(%)
CUB-200-2011 resnet50 88.4
Stanford-Cars resnet50 95.3
FGVC-Aircraft resnet50 94.0

Citation

If you find this paper useful in your research, please consider citing:

@ARTICLE{9350209,
author={Y. {Ding} and Z. {Ma} and S. {Wen} and J. {Xie} and D. {Chang} and Z. {Si} and M. {Wu} and H. {Ling}},
journal={IEEE Transactions on Image Processing},
title={AP-CNN: Weakly Supervised Attention Pyramid Convolutional Neural Network for Fine-Grained Visual Classification},
year={2021},
volume={30},
number={},
pages={2826-2836},
doi={10.1109/TIP.2021.3055617}}

Contact

Thanks for your attention! If you have any suggestion or question, you can leave a message here or contact us directly:

ap-cnn_pytorch-master's People

Contributors

dependabot[bot] avatar dingyf05 avatar dongliangchang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ap-cnn_pytorch-master's Issues

About baseline

Hi,

I recently did some research on fine-grained classification, and I noticed that you achieve AP 84.1 on CUB_200_2011 with baseline Resnet50 in your paper. Are the super-parameters like 'lr', 'decay' and so on the same as that in your code when training on baseline? And should I change the last fc layer of Resnet50 into 200 num_classes when training? I have been troubled by this for some time, as in my experiments, I can only get AP 82.9, while in some papers Resnet50 can go far to even 85.6 on CUB_200_2011.

My setting is as follows:
1 lr=0.01, momentum =0.9, weight-decay=1e-4
2 I use 10 epochs warm-up and then cosine decay like you
3 I change the 1000 num_classes into 200 in the last fc_layer
4 input is 448*448

Hope to get help from you. It did bother me for some time.

Thank you.

Kind regards.

关于可视化

感谢您优秀的工作!
想请教一下对于论文中各层特征的黑白可视化图是用什么工具实现,能否提供可视化的思路或者代码。
非常感谢!

cannot unsqueeze empty tensor

excellent work!
I have some difficulties when I tried to use AP-CNN to train my customized dataset.
the error was raised in "line 452, def get_att_roi" , I wonder if this error has been encountered before and what I can do to avoid this

BugReport

1.You should declare the operating system and GPU environment.
Torch0.4.1 + CUDA9.0 will cause an error if run your code on a gpu with a version higher than 2080Ti.
Switch to CUDA9.2 to run through the code.

  1. lib pyyaml must >= 5.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.