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

Attribute Predictions #109

Open ishmnnit opened 4 years ago

ishmnnit commented 4 years ago

I like to do attribute prediction on my dataset. I am trying to use the following -

python tools/test_predictor.py --config configs/attribute_predict_coarse/global_predictor_resnet_attr.py --checkpoint checkpoints/model_best.pth I created an empty file for test_attr.txt, test_cate.txt & test_bbox.txt and image path in test.txt.

I am getting the following error.

 File "/opt/miniconda/lib/python3.7/site-packages/mmfashion-0.4.0-py3.7.egg/mmfashion/apis/test_predictor.py", line 25, in test_predictor
    _non_dist_test_attr(model, dataset, cfg, validate=validate)
  File "/opt/miniconda/lib/python3.7/site-packages/mmfashion-0.4.0-py3.7.egg/mmfashion/apis/test_predictor.py", line 63, in _non_dist_test_attr
    for batch_idx, testdata in enumerate(data_loader):
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/opt/miniconda/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/miniconda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/miniconda/lib/python3.7/site-packages/mmfashion-0.4.0-py3.7.egg/mmfashion/datasets/Attr_Pred.py", line 115, in __getitem__
    return self.get_basic_item(idx)
  File "/opt/miniconda/lib/python3.7/site-packages/mmfashion-0.4.0-py3.7.egg/mmfashion/datasets/Attr_Pred.py", line 75, in get_basic_item
    bbox_cor = self.bboxes[idx]
IndexError: index 0 is out of bounds for axis 0 with size 0

I am able to do the predictions using demo/test_attr_predictor.py but the inference is quite slow for a large number of the image datasets.