wangchen1801 / FPD

Official code of the paper "Fine-Grained Prototypes Distillation for Few-Shot Object Detection (AAAI 2024)"
https://arxiv.org/pdf/2401.07629.pdf
27 stars 4 forks source link

ImportError: cannot import name 'DistributedSampler' from 'mmcls.datasets.builder' #3

Closed ylrccc closed 4 months ago

ylrccc commented 7 months ago

Hello, excuse me! I'm having this problem at runtime, but I'm almost following the steps in the readme to run the configuration, so I'd like to ask how to solve this problem? Traceback (most recent call last): File "train.py", line 18, in <module> import mmfewshot # noqa: F401, F403 File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/__init__.py", line 6, in <module> from .classification import * # noqa: F401, F403 File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/__init__.py", line 2, in <module> from .apis import * # noqa: F401,F403 File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/apis/__init__.py", line 2, in <module> from .inference import (inference_classifier, init_classifier, File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/apis/inference.py", line 14, in <module> from mmfewshot.classification.models import BaseMetricClassifier File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/models/__init__.py", line 5, in <module> from .classifiers import * # noqa: F401,F403 File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/models/classifiers/__init__.py", line 8, in <module> from .maml import MAML File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/models/classifiers/maml.py", line 10, in <module> from mmfewshot.classification.datasets import label_wrapper File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/datasets/__init__.py", line 5, in <module> from .builder import (build_dataloader, build_dataset, File "/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmfewshot/classification/datasets/builder.py", line 7, in <module> from mmcls.datasets.builder import DATASETS, DistributedSampler, worker_init_fn ImportError: cannot import name 'DistributedSampler' from 'mmcls.datasets.builder' (/home/ubuntu/anaconda3/envs/fpd01/lib/python3.8/site-packages/mmcls/datasets/builder.py)

wangchen1801 commented 7 months ago

Hello, it seems that your mmfewshot didn't install correctly. Please make sure to follow the steps below:

# install mmfewshot
pip install git+https://github.com/open-mmlab/mmfewshot.git
# or manually download the code, then
# cd mmfewshot
# pip install .

Do not use mim to install it:

mim install mmfewshot  # bugs

Feel free to ask if you still have any questions.

ylrccc commented 7 months ago

非常感谢你的回复! 我是按照步骤一步一步运行的,但是到mmdet的安装时,使用

mim install mmdet==2.24.0

就会出现下面图片中的问题 微信图片_20240304152117

所以我就只把这句换成了清华镜像 pip install mmdet==2.24.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

其他的语句都是没变的,但后面还是出现了一个新问题 Traceback (most recent call last): File "train.py", line 242, in <module> main() File "train.py", line 159, in main cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config))) File "/home/ubuntu/anaconda3/envs/fpd02/lib/python3.8/site-packages/mmcv/utils/config.py", line 596, in dump f.write(self.pretty_text) File "/home/ubuntu/anaconda3/envs/fpd02/lib/python3.8/site-packages/mmcv/utils/config.py", line 508, in pretty_text text, _ = FormatCode(text, style_config=yapf_style, verify=True) TypeError: FormatCode() got an unexpected keyword argument 'verify'

wangchen1801 commented 7 months ago

Please try this:

pip install yapf==0.40.1

it can solve the problem in my evironment~

ylrccc commented 7 months ago

Thank you very much! The problem has been solved! Thank you thank you thank you!