open-mmlab / mmfashion

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

Can't run Coarse Attribute Prediction #99

Open SikandAlex opened 4 years ago

SikandAlex commented 4 years ago

1) Clone project

2) pip3 install scikit-build

3) python setup.py install

4) Download Coarse Attribute Pre-Trained Model File here [ https://drive.google.com/file/d/1bOL4GhLyBEcXgATiVcZ-g3RD8xhKsj5f/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=1bOL4GhLyBEcXgATiVcZ-g3RD8xhKsj5f' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1bOL4GhLyBEcXgATiVcZ-g3RD8xhKsj5f" -O fine.pth && rm -rf /tmp/cookies.txt

5) Download Anno_Coarse folder from here https://drive.google.com/drive/folders/0B7EVK8r0v71pWWxJeGVqMjRkUVE

Place it in the proper directory

6) python test_attr_predictor.py --checkpoint latest.pth --input test.jpg

Traceback (most recent call last):
  File "test_attr_predictor.py", line 62, in <module>
    main()
  File "test_attr_predictor.py", line 45, in main
    model = build_predictor(cfg.model)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 87, in build_predictor
    return build(cfg, PREDICTOR)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 38, in build
    return _build_module(cfg, registry, default_args)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 30, in _build_module
    return obj_type(**args)
TypeError: __init__() got an unexpected keyword argument 'loss_attr'

7) According to #86 change the init()method in mmfashion/mmfashion/models/predictor/global_predictor.py and add a parameter los_attr

def __init__(self,
                 backbone,
                 global_pool,
                 attr_predictor,
                 loss_attr, #ADDED LOSS_ATTR HERE
                 cate_predictor=None,
                 roi_pool=None,
                 pretrained=None):
        super(GlobalPredictor, self).__init__()

        self.backbone = builder.build_backbone(backbone)
        self.global_pool = builder.build_global_pool(global_pool)
        self.attr_predictor = builder.build_attr_predictor(attr_predictor)

        self.loss_attr = builder.build_loss(loss_attr)

8) Same error occurs

Traceback (most recent call last):
  File "test_attr_predictor.py", line 62, in <module>
    main()
  File "test_attr_predictor.py", line 45, in main
    model = build_predictor(cfg.model)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 87, in build_predictor
    return build(cfg, PREDICTOR)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 38, in build
    return _build_module(cfg, registry, default_args)
  File "/Users/alex/DeepFashion/mmfashion/mmfashion/models/builder.py", line 30, in _build_module
    return obj_type(**args)
TypeError: __init__() got an unexpected keyword argument 'loss_attr'

Python 3.7.7

@liuziwei7 @veralauee @hellock

piggybox commented 4 years ago

Thanks for the info. I've followed the list and fixed the final issue. You have to add that 'loss_attr' to the file in the site-package rather than to the one in the current folder which is github cloned.

The output I got looks like this

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

[ Top3 Attribute Prediction ]
sleeve
knit
striped
[ Top5 Attribute Prediction ]
sleeve
knit
striped
stripe
denim
[ Top10 Attribute Prediction ]
sleeve
knit
striped
stripe
denim
leather
lace
maxi
shirt
wash

There's still error I hope I can figure out. Not sure if that affects the accuracy of the output.

AhmedNageh08 commented 3 years ago

@SikandAlex same error , did you find any solution ?

AhmedNageh08 commented 3 years ago

i found it ..you should add loss_attr in /usr/local/lib/python3.6/dist-packages/mmfashion-0.4.0-py3.6.egg/mmfashion/models/predictor/global_predictor.py and it'll work

Dogacel commented 3 years ago

I think it works but the prediction confidences are pretty low.