Pytorch implementation of the Trans paper "Few-Shot Learning for Domain-Specific Fine-Grained Image Classification"
For example, the 2-th category Pullover (green color) and 6-th category Shirt (pink color). Centerloss is difficult to form their own cluster fastly and robustly.
Performance in general classification tasks.
python3 test_loss.py
Accuracy | Softmax loss | Center loss | CN loss |
---|---|---|---|
(%) | 89.5± 0.2 | 90.0±0.2 | 91.42±0.3 |
The three use a unified network and parameter settings.
-
Download CUB_200_2011 Dataset. Unzip and locate it in this directory.
/home/***/datasets/CUB_200_2011/
-
If you want the focus-areas generated by us. Download CUB_Attention_Area.
/home/***/datasets/CUB_Attention/
-
If you want the focus-areas generated by yourself. ( Grad-cam and crop-resize operation are about 9 images per second. )
-
Please re-training model.
-
Run
python3 generate_cub_focus.py
-
Default testing, only on novel classes and without focus-areas.
cd CUB
python3 test_cub.py
You can change the switch of "withAtt", "novelonly","SUPPORT_NUM" of test_cub.py.
python3 train_cub.py
-
Download miniPPlankton. Unzip and locate it in this directory.
/home/***/datasets/phytoplankton/fewshot/
| SmallTrain
| SmallTest
-
Download miniPPlanktonFocusAreas.Unzip and locate it in this directory. (You can also generate them during the training and testing process.)
/home/***/datasets/phytoplankton/fewshot/
| SmallTrainAtt
| SmallTestAtt
python3 test_plank.py
The experimental results here use a pre-trained ( ImageNet ) model.
Acc(%) | 5way-1shot | 5way-5shot | 10way-1shot | 10way-5shot |
---|---|---|---|---|
Imprint | 81.55 | 93.27 | 71.93 | 89.65 |
+CNloss | 83.24 | 93.79 | 73.76 | 90.31 |
+Att | 83.35 | 94.10 | 73.9 | 90.45 |
The model may have reached the data bottleneck, using "Att" only brings a slight boost.
- Please refer to the citations in this paper for miniDogs datasets.
- The center point dimension of loss functions can be set by itself.