chou141253 / FGVC-PIM

Pytorch implementation for "A Novel Plug-in Module for Fine-Grained Visual Classification". fine-grained visual classification task.
MIT License
186 stars 39 forks source link

How to train on CUB #15

Closed JingjunYi closed 2 years ago

JingjunYi commented 2 years ago

Thanks for your great job! I have browsed your code and I found that the data is read in through the ImageDataset class, but it does not seem to fit the original format of the CUB dataset. Did you change the format of the original CUB dataset when you performed your experiments, and if so, can you please tell me how you did it? 1

JingjunYi commented 2 years ago

I tried to write my own dataloader to solve my problem, here is the link of my project. https://github.com/Blackpinkup/FGVC-PIM

OhJackHu commented 2 years ago

Hi, bro, How to load pre-training weights that have been downloaded. I used the following code but reported an error: self.extractor = timm.create_model('swin_large_patch4_window12_384_in22k', pretrained=False) self.extractor = load_model_weights(self.extractor, './swin_large_patch4_window12_384_in22k.pth')

Traceback (most recent call last): File "train.py", line 400, in train_loader, test_loader, model, optimizer, schedule = set_environment(args) File "train.py", line 97, in set_environment model = SwinVit12( File "/home/pengtl/jackhu/FGVC-PIM-master/models/SwinVit12.py", line 235, in init self.extractor = load_model_weights(self.extractor, "/home/pengtl/jackhu/swin_large_patch4_window12_384_22k.pth") File "/home/pengtl/jackhu/FGVC-PIM-master/models/SwinVit12.py", line 16, in load_model_weights if key in state['state_dict']: KeyError: 'state_dict'

JingjunYi commented 2 years ago

@OhJackHu I met the same problem. If you don't want to download pretrained model in C drive, then you have to modify timm folder to load your pretrianed model. But the simplest solution is to put your pretrained model in C drive to replace torch hub. The path should be torch/hub/checkpoint.

JingjunYi commented 2 years ago

I solved my problem by adding my own dataloader for CUB like datasets, hope my project can help you. https://github.com/Blackpinkup/FGVC-PIM