mmfashion icon indicating copy to clipboard operation
mmfashion copied to clipboard

Backbone model

Open DaniellePerri1 opened this issue 4 years ago • 6 comments

TL;DR: Can you please describes exactly from where should I download the Resnet18 model for the compatibility?

I followed https://github.com/open-mmlab/mmfashion/issues/51 and tried download the pre-trained resnet18 model using pytorch, in order to run the comparability demo, as follows:

import torch import torchvision.models as models resnet18 = models.resnet18(pretrained=True) torch.save(resnet18, '/content/mmfashion/checkpoint/resnet18.pth')

But when running the demo, I get the following RuntimeError:

RuntimeError: No state_dict found in checkpoint file checkpoint/resnet18.pth

In the other hand, when I download from the same path the original paper ("Learning_the_type_aware_embedding") downloaded in their code (https://download.pytorch.org/models/resnet18-5c106cde.pth), it indeed works but gives non-deterministic scores (e.g. first run give 1.94 score on set3, while another gives 0.241), and follows some warnings/error messages as describes in the following screenshot:

image

**My questions are:

  1. Does the score should be non-deterministic? I've read the "type aware" paper, and all the parts look to be deterministic.
  2. Should I get these error/warning?
  3. Can you please describes exactly from where you downloaded the Resnet18 model?**

Thanks in advance !!

DaniellePerri1 avatar Jun 25 '20 12:06 DaniellePerri1

TL;DR: Can you please describes exactly from where should I download the Resnet18 model for the compatibility?

I followed #51 and tried download the pre-trained resnet18 model using pytorch, in order to run the comparability demo, as follows:

import torch import torchvision.models as models resnet18 = models.resnet18(pretrained=True) torch.save(resnet18, '/content/mmfashion/checkpoint/resnet18.pth')

But when running the demo, I get the following RuntimeError:

RuntimeError: No state_dict found in checkpoint file checkpoint/resnet18.pth

In the other hand, when I download from the same path the original paper ("Learning_the_type_aware_embedding") downloaded in their code (https://download.pytorch.org/models/resnet18-5c106cde.pth), it indeed works but gives non-deterministic scores (e.g. first run give 1.94 score on set3, while another gives 0.241), and follows some warnings/error messages as describes in the following screenshot:

image

**My questions are:

1. Does the score should be non-deterministic? I've read the "type aware" paper, and all the parts look to be deterministic.

2. Should I get these error/warning?

3. Can you please describes exactly from where you downloaded the Resnet18 model?**

Thanks in advance !!

Hello This is my problem too. Have you solved it?

Ebimsv avatar Jun 29 '20 12:06 Ebimsv

TL;DR: Can you please describes exactly from where should I download the Resnet18 model for the compatibility? I followed #51 and tried download the pre-trained resnet18 model using pytorch, in order to run the comparability demo, as follows: import torch import torchvision.models as models resnet18 = models.resnet18(pretrained=True) torch.save(resnet18, '/content/mmfashion/checkpoint/resnet18.pth') But when running the demo, I get the following RuntimeError:

RuntimeError: No state_dict found in checkpoint file checkpoint/resnet18.pth

In the other hand, when I download from the same path the original paper ("Learning_the_type_aware_embedding") downloaded in their code (https://download.pytorch.org/models/resnet18-5c106cde.pth), it indeed works but gives non-deterministic scores (e.g. first run give 1.94 score on set3, while another gives 0.241), and follows some warnings/error messages as describes in the following screenshot: image **My questions are:

1. Does the score should be non-deterministic? I've read the "type aware" paper, and all the parts look to be deterministic.

2. Should I get these error/warning?

3. Can you please describes exactly from where you downloaded the Resnet18 model?**

Thanks in advance !!

Hello This is my problem too. Have you solved it?

Unfortunately, no. Waiting for any insight from the authors .

DaniellePerri1 avatar Jun 29 '20 13:06 DaniellePerri1

Several issues to clarify:

  1. The following code to load pretrained weights is wrong. resnet18 = models.resnet18(pretrained=True) Here, resnet18 is a model, not a state dict. You can not load a model(resnet18) to another model(our recommender). In this case, you should just use Resnet18 pretrained weights.

  2. Resnet18 is used as backbone here that consists part of the whole recommender structure, it can not be used as a recommender. In your implementation, you want to use this resnet18 to do fashion recommendation task, it's incorrect.

  3. I am not very clear about what is the same path of the original paper. But similar, you cannot hope resnet18 can serve as the recommendation model. It's just a backbone.

veralauee avatar Jun 29 '20 18:06 veralauee

Thanks! I indeed didn't notice that I saved the model itself instead of the state dict :)

Anyway, the compatibility score in the demo is still non deterministic, even though all the steps in the "type aware" paper are deterministic (for example, in a one run on Set3 I got 0.307 compatibility score, while in another run on Set3 I got 0.124). There is any reason why the score is non deterministic, or maybe I made something wrong during the setup?

Setup details:

  • For the backbone I used resnet18 pre-trained weights (downloaded using torchvision.models).
  • For the checkpoint, I downloaded the first model in the "Fashion Compatibility Predictor" section in MODEL_ZOO.md.
  • I test the demo on Set3. (I got no warnings or errors)

Thanks again!

DaniellePerri1 avatar Jul 03 '20 17:07 DaniellePerri1

I have same issue. Any solution?

agniszczotka avatar Jun 22 '21 10:06 agniszczotka

@agniszczotka This worked for me:

import torch
import torchvision

model = torchvision.models.resnet50(pretrained=True, progress=True)
torch.save(model.state_dict(), 'checkpoint/resnet50.pth')

Replace resnet50 with resnet18 if you need so.

@DaniellePerri1 Could #107 be the solution to the non-deterministic behavior?

hadipash avatar Jul 09 '21 02:07 hadipash