Home

Awesome

Large Scale Fine-Grained Categorization and Domain-Specific Transfer Learning

Tensorflow code and models for the paper:

Large Scale Fine-Grained Categorization and Domain-Specific Transfer Learning
Yin Cui, Yang Song, Chen Sun, Andrew Howard, Serge Belongie
CVPR 2018

This repository contains code and pre-trained models used in the paper and 2 demos to demonstrate: 1) the importance of pre-training data on transfer learning; 2) how to calculate domain similarity between source domain and target domain.

Notice that we used a mini validation set (./inat_minival.txt) contains 9,697 images that are randomly selected from the original iNaturalist 2017 validation set. The rest of valdiation images were combined with the original training set to train our model in the paper. There are 665,473 training images in total.

Dependencies:

Preparation:

git clone --recursive https://github.com/richardaecn/cvpr18-inaturalist-transfer.git

Datasets (optional):

In the paper, we used data from 9 publicly available datasets:

We provide a download link that includes the entire CUB-200-2011 dataset and data splits for the rest of 8 datasets. The provided link contains sufficient data for this repo. If you would like to use other 8 datasets, please download them from the official websites and put them in the corresponding subfolders under './data'.

Pre-trained Models (optional):

The models were trained using TensorFlow-Slim. We implemented Squeeze-and-Excitation Networks (SENet) under './slim'. The pre-trained models can be downloaded from the following links:

NetworkPre-trained DataInput SizeDownload Link
Inception-V3ImageNet299link
Inception-V3iNat2017299link
Inception-V3iNat2017448link
Inception-V3iNat2017299 -> 560 FT<sup>1</sup>link
Inception-V3ImageNet + iNat2017299link
Inception-V3 SEImageNet + iNat2017299link
Inception-V4iNat2017448link
Inception-V4iNat2017448 -> 560 FT<sup>2</sup>link
Inception-ResNet-V2ImageNet + iNat2017299link
Inception-ResNet-V2 SEImageNet + iNat2017299link
ResNet-V2 50ImageNet + iNat2017299link
ResNet-V2 101ImageNet + iNat2017299link
ResNet-V2 152ImageNet + iNat2017299link

<sup>1</sup> This model was trained with 299 input size on train + 90% val and then fine-tuned with 560 input size on 90% val.

<sup>2</sup> This model was trained with 448 input size on train + 90% val and then fine-tuned with 560 input size on 90% val.

TensorFlow Hub also provides a pre-trained Inception-V3 299 on iNat2017 original training set here.

Featrue Extraction (optional):

Run the following Python script to extract feature:

python feature_extraction.py

To run this script, you need to download the checkpoint of Inception-V3 299 trained on iNat2017. The dataset and pre-trained model can be modified in the script.

We provide a download link that includes features used in the domos of this repo.

Demos

  1. Linear logistic regression on extracted features:

This demo shows the importance of pre-training data on transfer learning. Based on features extracted from an Inception-V3 pre-trained on iNat2017, we are able to achieve 89.9% classification accuracy on CUB-200-2011 with the simple logistic regression, outperforming most state-of-the-art methods.

LinearClassifierDemo.ipynb
  1. Calculating domain similarity by Earth Mover's Distance (EMD): This demo gives an example to calculate the domain similarity proposed in the paper. Results correspond to part of the Fig. 5 in the original paper.
DomainSimilarityDemo.ipynb

Training and Evaluation

python convert_dataset.py --dataset_name=cub_200 --num_shards=10
CUDA_VISIBLE_DEVICES=0 ./train.sh
CUDA_VISIBLE_DEVICES=1 ./eval.sh
tensorboard --logdir=./checkpoints/cub_200/ --port=6006

Citation

If you find our work helpful in your research, please cite it as:

@inproceedings{Cui2018iNatTransfer,
  title = {Large Scale Fine-Grained Categorization and Domain-Specific Transfer Learning},
  author = {Yin Cui, Yang Song, Chen Sun, Andrew Howard, Serge Belongie},
  booktitle={CVPR},
  year={2018}
}