open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.59k stars 9.46k forks source link

Inference error: AttributeError: module 'pycocotools' has no attribute '__version__'` #7037

Open Williamlizl opened 2 years ago

Williamlizl commented 2 years ago

`AttributeError Traceback (most recent call last)

in 5 import torch 6 from mmcv import Config ----> 7 from mmdet.apis import inference_detector, init_detector, show_result_pyplot 8 import os 9 import glob ~/mmdetection/mmdet/apis/__init__.py in 2 init_detector, show_result_pyplot) 3 from .test import multi_gpu_test, single_gpu_test ----> 4 from .train import get_root_logger, set_random_seed, train_detector 5 6 __all__ = [ ~/mmdetection/mmdet/apis/train.py in 9 10 from mmdet.core import DistEvalHook, EvalHook ---> 11 from mmdet.datasets import (build_dataloader, build_dataset, 12 replace_ImageToTensor) 13 from mmdet.utils import get_root_logger ~/mmdetection/mmdet/datasets/__init__.py in 1 from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset ----> 2 from .cityscapes import CityscapesDataset 3 from .coco import CocoDataset 4 from .custom import CustomDataset 5 from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset, ~/mmdetection/mmdet/datasets/cityscapes.py in 14 15 from .builder import DATASETS ---> 16 from .coco import CocoDataset 17 18 ~/mmdetection/mmdet/datasets/coco.py in 19 import pycocotools 20 if not hasattr(pycocotools, '__sphinx_mock__'): # for doc generation ---> 21 assert pycocotools.__version__ >= '12.0.2' 22 except AssertionError: 23 raise AssertionError('Incompatible version of pycocotools is installed. ' AttributeError: module 'pycocotools' has no attribute '__version__'`
shehaodong commented 2 years ago

mmdetection has its own pycocotools, so you need to 'pip uninstall pycocotools', and then go to 'pip install mmpycocotools'.