Skip to content

Codes for "Few-shot Image Classification: Just Use a Library of Pre-trained Feature Extractors and a Simple Classifier"

License

Notifications You must be signed in to change notification settings

arjish/PreTrainedFullLibrary_FewShot

Repository files navigation

Few-shot Image Classification: Just Use a Libraryof Pre-trained Feature Extractors and a Simple Classifier: paper

Accepted at ICCV 2021

Use the following links to download the data:

  1. ILSVRC2012: Register at ImageNet and request for a username and an access key to download ILSRVC-2012 data set.

  2. CUB-200-2011 Birds: Birds

  3. FGVC-Aircraft: Aircraft

  4. FC100: FC100

  5. Omniglot: Omniglot

  6. Texture: Texture

  7. Traffic Sign: Traffic Sign

  8. FGCVx Fungi: Fungi Annotations

  9. Quick Draw: Quick Draw

  • Use gsutil to download the data:
gsutil -m cp gs://quickdraw_dataset/full/numpy_bitmap/*.npy data/quickdraw
  1. VGG Flower: VGG Flower, Labels

Extracting Pretrained Library Features (PyTorch):

python extract_pretrained_features.py <path_to_data> -f <result_folder> -b <batch_size> --gpu <gpu_ID>

Few-shot training and testing:

  • Single library classifier example:
python classifier_single.py data/aircraft --model resnet18 --nway 5 --kshot 1 --kquery 15 --num_epochs 200 --n_problems 600 --hidden_size 512 --lr 0.001 --gamma 0.2
  • Full library classifier example:
python classifier_full_library.py data/aircraft --nway 20 --kshot 5 --kquery 15 --num_epochs 100 --n_problems 600 --hidden_size 512 --lr 0.0005 --gamma 0.1

Selected arguments

  • data_path: path to the folder containing all images: data/<dataset>
  • --model: model name for single classifier (Resnet18, Densenet121, etc.)
  • --gpu: GPU ID to be used
  • Hyperparameters
    • --lr: learning rate for the classifier: 0.001
    • --kshot: number of images from each class in training set: 1
    • --kquery: number of images from each class in test set: 15
    • --nway: number of classes per task: 5
    • --hidden_size: hidden state size for the classifier: 1024
    • --num_epochs: number of training epochs: 100
    • --n_problems: number of tasks used for testing: 600
    • --gamma: L2 regularization constant: 0.5
    • --linear: Use for a linear NN architecture (no hidden layer)
    • --nol2: Use to get rid of L2 regularization
    • --soft: Use for soft bagging when applying ensemble method, otherwise hard bagging

About

Codes for "Few-shot Image Classification: Just Use a Library of Pre-trained Feature Extractors and a Simple Classifier"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages