mmpretrain: [Bug] Run demo error
Branch
main branch (mmpretrain version)
Describe the bug
I installed the mmpretrain according to the documentation, but failed in Verify the installation section.
The following is the error message (copied from terminal).
~/Documents/Fau/Projects.nosync/Python_Projects/mmpretrain (main) » python demo/image_demo.py demo/demo.JPEG resnet18_8xb32_in1k --device cpu
Loads checkpoint by http backend from path: https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_8xb32_in1k_20210831-fbbb1da6.pth
Inference ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Traceback (most recent call last):
File "/Users/Fau/Documents/Fau/Projects.nosync/Python_Projects/mmpretrain/demo/image_demo.py", line 44, in <module>
main()
File "/Users/Fau/Documents/Fau/Projects.nosync/Python_Projects/mmpretrain/demo/image_demo.py", line 37, in main
result = inferencer(args.img, show=args.show, show_dir=args.show_dir)[0]
File "/Users/Fau/Documents/Fau/Projects.nosync/Python_Projects/mmpretrain/mmpretrain/apis/image_classification.py", line 123, in __call__
return super().__call__(inputs, return_datasamples, batch_size,
File "/usr/local/Caskroom/miniconda/base/envs/dl/lib/python3.10/site-packages/mmengine/infer/infer.py", line 221, in __call__
results = self.postprocess(preds, visualization, return_datasamples,
File "/Users/Fau/Documents/Fau/Projects.nosync/Python_Projects/mmpretrain/mmpretrain/apis/image_classification.py", line 221, in postprocess
result['pred_class'] = self.classes[pred_label]
IndexError: list index out of range
Environment
{'sys.platform': 'darwin',
'Python': '3.10.10 (main, Mar 21 2023, 13:41:39) [Clang 14.0.6 ]',
'CUDA available': False,
'numpy_random_seed': 2147483648,
'GCC': 'Homebrew clang version 16.0.2',
'PyTorch': '2.0.0',
'TorchVision': '0.15.1',
'OpenCV': '4.7.0',
'MMEngine': '0.7.3',
'MMCV': '2.0.0',
'MMPreTrain': '1.0.0rc7+e80418a'}
Other information
MacBook Pro 16-inch (Intel) MacOS 13.3.1a
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 26
There has been the same issue in PyTorch refer to https://github.com/pytorch/pytorch/issues/92311.
PyTorch would fix it in the next version.