open-mmlab / mmfashion

Open-source toolbox for visual fashion analysis based on PyTorch
https://open-mmlab.github.io/
Apache License 2.0
1.25k stars 281 forks source link

Backbone model #71

Open DaniellePerri1 opened 4 years ago

DaniellePerri1 commented 4 years ago

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 !!

Ebimsv commented 4 years ago

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?

DaniellePerri1 commented 4 years ago

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 .

veralauee commented 4 years ago

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.

DaniellePerri1 commented 4 years ago

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:

Thanks again!

agniszczotka commented 3 years ago

I have same issue. Any solution?

hadipash commented 3 years ago

@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?