mmfashion
mmfashion copied to clipboard
Feel so difficult to run your demo
what about the error occurred when building the model "The model and loaded state dict do not match exactly" unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias
It means that you didn't load the correct model. Please make sure your path is right.
Hi,
I am having the same issue with your demo code test_cate_attr_predictor.py. While loading it says, the model and loaded state dict do not match exactly" unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias. And consequently predictions are also coming out to be random.
Can you please attach the weights for global_predictor_vgg.py model in this issue?
Hi,
I am having the same issue with your demo code test_cate_attr_predictor.py. While loading it says, the model and loaded state dict do not match exactly" unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias. And consequently predictions are also coming out to be random.
Can you please attach the weights for global_predictor_vgg.py model in this issue?
We already provided the pretrained models in model.zoo. https://github.com/open-mmlab/mmfashion/blob/master/docs/MODEL_ZOO.md
Hi,
Thank you for providing me the link for the pretrained models, but I downloaded the correct models from this link only. These 2 demo files I was trying to run:
-
python3 test_cate_attr_predictor.py --input demo/imgs/05_1_side.jpg --checkpoint ./../latest_global.pth --config configs/category_attribute_predict/global_predictor_vgg.py
In this case, I am getting this warning while loading the model and my predictions are also not coming out to be good.

Using this link, I am downloading the pertained model for my first case. https://drive.google.com/file/d/10SZ3Lw4U0F9OKAuHWc-tBbvLS6yfE_x8/view
- `python3 test_cate_attr_predictor.py --input demo/imgs/05_1_side.jpg --checkpoint ./../latest_landmark.pth --config configs/category_attribute_predict/roi_predictor_vgg.py'
In this second case, I am using ROI pooling. But I am not able to run the code. I have attached my stack trace.
For this case, I downloaded the pretrained model from here https://drive.google.com/file/d/17XlihpZS9iY__i7rPxqlzpenHHRSbLGa/view
Can you please give me some insights into this?
@ashisharora010 @veralauee
I have tried for a week straight to get this repository working and I'm still not having much luck.
Can't run coarse attribute prediction at all
Although the author's claimed 99% accuracy for Top-5 coarse attribute prediction I could not get that demo running at all. Other users have complained of bad predictions and the authors of this code instructed us to use the new Anno_fine data so I've abandoned coarse prediction for now.
See #99
Initial Setup for Fine Attribute Prediction
Download the new Anno_fine
folder to use with model
https://drive.google.com/drive/folders/19J-FY5NY7s91SiHpQQBo2ad3xjIB42iN
Fine Attributes VGG-16 Global Pooling (poor performance)
1) Download the VGG16 model from PyTorch
wget https://download.pytorch.org/models/vgg16-397923af.pth -O checkpoint/vgg16.pth
2) Download the pre-trained model from Category and Attribute Prediction (Fine) VGG16 Global Pooling from here
https://drive.google.com/file/d/10SZ3Lw4U0F9OKAuHWc-tBbvLS6yfE_x8/view?usp=sharing
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=10SZ3Lw4U0F9OKAuHWc-tBbvLS6yfE_x8' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=10SZ3Lw4U0F9OKAuHWc-tBbvLS6yfE_x8" -O finevgg16global.pth && rm -rf /tmp/cookies.txt
3) Prepare a test image
4) Get Predictions
python3 test_cate_attr_predictor.py --input floraltest.jpg --checkpoint ./finevgg16global.pth --config ../configs/category_attribute_predict/global_predictor_vgg.py
5) Output
pretrained model checkpoint/vgg16.pth
The model and loaded state dict do not match exactly
unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias
model loaded from ./finevgg16global.pth
[ Top3 Attribute Prediction ]
conventional
sleeveless
cotton
[ Top5 Attribute Prediction ]
conventional
sleeveless
cotton
no_neckline
mini_length
[ Top10 Attribute Prediction ]
conventional
sleeveless
cotton
no_neckline
mini_length
floral
maxi_length
crew_neckline
chiffon
solid
[ Top1 Category Prediction ]
Dress
[ Top3 Category Prediction ]
Dress
Jumpsuit
Romper
[ Top5 Category Prediction ]
Dress
Jumpsuit
Romper
Skirt
Blouse
6) Try another test image
7) Output
pretrained model checkpoint/vgg16.pth
The model and loaded state dict do not match exactly
unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias
model loaded from ./finevgg16global.pth
[ Top3 Attribute Prediction ]
no_dress
solid
no_neckline
[ Top5 Attribute Prediction ]
no_dress
solid
no_neckline
conventional
sleeveless
[ Top10 Attribute Prediction ]
no_dress
solid
no_neckline
conventional
sleeveless
cotton
denim
long_sleeve
tight
loose
[ Top1 Category Prediction ]
Jeans
[ Top3 Category Prediction ]
Jeans
Joggers
Shorts
[ Top5 Category Prediction ]
Jeans
Joggers
Shorts
Leggings
Sweatpants
Fine Attributes VGG16 ROI Pooling (does not work at all)
1) Download the VGG16 model from PyTorch
wget https://download.pytorch.org/models/vgg16-397923af.pth -O checkpoint/vgg16.pth
2) Download the pre-trained model from Category and Attribute Prediction (Fine) VGG16 Landmark Pooling from here
https://drive.google.com/file/d/17XlihpZS9iY__i7rPxqlzpenHHRSbLGa/view
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=17XlihpZS9iY__i7rPxqlzpenHHRSbLGa' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=17XlihpZS9iY__i7rPxqlzpenHHRSbLGa" -O finevgg16landmark.pth && rm -rf /tmp/cookies.txt
3) Prepare a test image
4) Get Predictions
python3 test_cate_attr_predictor.py --input jeans.jpg --checkpoint ./finevgg16landmark.pth --config ../configs/category_attribute_predict/roi_predictor_vgg.py
5) Error / Output
pretrained model checkpoint/vgg16.pth
The model and loaded state dict do not match exactly
unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias
model loaded from ./finevgg16landmark.pth
Traceback (most recent call last):
File "test_cate_attr_predictor.py", line 65, in <module>
main()
File "test_cate_attr_predictor.py", line 56, in main
landmark=landmark_tensor, return_loss=False)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in __call__
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/predictor/base.py", line 41, in forward
return self.forward_test(img, landmark)
File "/usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/predictor/base.py", line 29, in forward_test
return self.simple_test(img[0], landmark[0])
File "/usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/predictor/roi_attr_cate_predictor.py", line 56, in simple_test
attr_pred, cate_pred = self.aug_test(x, landmark)
File "/usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/predictor/roi_attr_cate_predictor.py", line 64, in aug_test
local_x = self.roi_pool(x, landmark)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in __call__
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/roi_pool/roi_pooling.py", line 51, in forward
landmarks = landmarks.view(batch_size, self.num_lms, 2)
RuntimeError: shape '[1, 8, 2]' is invalid for input of size 1
Fine Attributes ResNet50 Global Pooling (does not work at all)
1) Download the ResNet50 model from PyTorch
wget https://download.pytorch.org/models/resnet50-19c8e357.pth -O checkpoint/resnet50.pth
2) Download the pre-trained model from Category and Attribute Prediction (Fine) ResNet50 Global Pooling from here
https://drive.google.com/file/d/1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45/view
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45" -O fineresnet50global.pth && rm -rf /tmp/cookies.txt
3) Prepare a test image
4) Get Predictions
python3 test_cate_attr_predictor.py --input jeans.jpg --checkpoint ./fineresnet50global.pth --config ../configs/category_attribute_predict/global_predictor_resnet.py
5) Error / Output
pretrained model checkpoint/resnet50.pth
The model and loaded state dict do not match exactly
unexpected key in source state_dict: fc.weight, fc.bias
The model and loaded state dict do not match exactly
unexpected key in source state_dict: roi_pool.linear.0.weight, roi_pool.linear.0.bias, concat.fc_fusion.weight, concat.fc_fusion.bias
model loaded from ./fineresnet50global.pth
[ Top3 Attribute Prediction ]
striped
pleated
embroidered
[ Top5 Attribute Prediction ]
striped
pleated
embroidered
chiffon
solid
[ Top10 Attribute Prediction ]
striped
pleated
embroidered
chiffon
solid
square_neckline
denim
knit
no_dress
crew_neckline
[ Top1 Category Prediction ]
Cape
[ Top3 Category Prediction ]
Cape
Chinos
Tee
[ Top5 Category Prediction ]
Cape
Chinos
Tee
Shorts
Poncho
Fine Attributes ResNet50 Landmark Pooling (does not work at all)
1) Download the ResNet50 model from PyTorch
wget https://download.pytorch.org/models/resnet50-19c8e357.pth -O checkpoint/resnet50.pth
2) Download the pre-trained model from Category and Attribute Prediction (Fine) ResNet50 Landmark Pooling from here
https://drive.google.com/file/d/1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45/view
Note
The ResNet Landmark Pooling / ResNet Global Pooling model links refer to the same file on https://github.com/open-mmlab/mmfashion/blob/master/docs/MODEL_ZOO.md (Not sure if this is an error by authors or not)
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1zsgxJAkdumpw4uDkapb1Ulq-aG1Hwz45" -O fineresnet50landmark.pth && rm -rf /tmp/cookies.txt
3) Prepare a test image
4) Get Predictions
python3 test_cate_attr_predictor.py --input jeans.jpg --checkpoint ./fineresnet50landmark.pth --config ../configs/category_attribute_predict/roi_predictor_resnet.py
5) Error / Output
pretrained model checkpoint/resnet50.pth
The model and loaded state dict do not match exactly
unexpected key in source state_dict: fc.weight, fc.bias
The model and loaded state dict do not match exactly
unexpected key in source state_dict: roi_pool.linear.0.weight, roi_pool.linear.0.bias, concat.fc_fusion.weight, concat.fc_fusion.bias
model loaded from ./fineresnetlandmark.pth
[ Top3 Attribute Prediction ]
striped
denim
no_dress
[ Top5 Attribute Prediction ]
striped
denim
no_dress
embroidered
solid
[ Top10 Attribute Prediction ]
striped
denim
no_dress
embroidered
solid
square_neckline
chiffon
v_neckline
pleated
knit
[ Top1 Category Prediction ]
Cape
[ Top3 Category Prediction ]
Cape
Tee
Jeggings
[ Top5 Category Prediction ]
Cape
Tee
Jeggings
Chinos
Poncho
I have now a similar issue even if I'm facing more inaccurate results. I would omit the result for avoiding confusion for now: please let me know if you need them.
In general I would suggest to be more precise about which is the model file that needs to go into the checkpoint/ folder: is the one available at this address? If I'm not wrong it has the same content as for the one suggested by @SikandAlex in the above comment?
I have tried ResNet50 model with landmark pooling for Coarse Attribute Prediction. After some fixes in source code ended up with the same issue @SikandAlex is having RuntimeError: shape '[1, 8, 2]' is invalid for input of size 1
. This toolbox seems promising, however, as issues section shows a lot of people have problems running it. Looking forward for more detailed docs to run the toolbox.
I have tried ResNet50 model with landmark pooling for Coarse Attribute Prediction. After some fixes in source code ended up with the same issue @SikandAlex is having
RuntimeError: shape '[1, 8, 2]' is invalid for input of size 1
. This toolbox seems promising, however, as issues section shows a lot of people have problems running it. Looking forward for more detailed docs to run the toolbox.
I stopped at this issue, too.
Hi, I am having the same issue with your demo code test_cate_attr_predictor.py. While loading it says, the model and loaded state dict do not match exactly" unexpected key in source state_dict: classifier.0.weight, classifier.0.bias, classifier.3.weight, classifier.3.bias, classifier.6.weight, classifier.6.bias. And consequently predictions are also coming out to be random. Can you please attach the weights for global_predictor_vgg.py model in this issue?
We already provided the pretrained models in model.zoo. https://github.com/open-mmlab/mmfashion/blob/master/docs/MODEL_ZOO.md
I faced the same issue. What the link provides are model weights and not complete model. If I try to create the model structure with vgg16 as backbone, the same error of unexpected key is faced, as the name for layers that the model provided in MODEL_ZOO has 'backbone.features.28.weight' but for vgg16 weights the names are 'features.28.weight'. So they don't match.
@veralauee why don't you provide the pretrained models itself, or a readme guiding how to build and use the checkpoints(/weights) given in this repo? That would be of great help to many researchers and users.
im glad to know im not the only one thats having the same exact issue
did you figure to resolve this issue? @fbarulli