在使用自己的数据集训练mmRotate的时候,已经按照教程修改好了所有的类别和类别数,但还是在运行python tools/train.py的时候遇到了以下的问题:
Traceback (most recent call last):
File "/root/autodl-tmp/mmrotate/tools/train.py", line 192, in
main()
File "/root/autodl-tmp/mmrotate/tools/train.py", line 168, in main
datasets = [build_dataset(cfg.data.train)]
File "/root/mmrotate/mmrotate/datasets/builder.py", line 47, in build_dataset
dataset = build_from_cfg(cfg, ROTATED_DATASETS, default_args)
File "/root/miniconda3/envs/mm/lib/python3.8/site-packages/mmcv/utils/registry.py", line 72, in build_from_cfg
raise type(e)(f'{obj_cls.__name__}: {e}')
KeyError: "DOTADataset: 'single'"
明明所有的参数已经修改好了,官网教程的验证也通过了,怎么就是不行呢……
于是在网上疯狂找解决方案,没有一个帖子能解决。最终功夫不负有心人,在下边这篇博客的评论区里找到了同样求助的大佬,他给出的建议是按照博客中的安装方法重新安装,或者把自己的标签改为原本标签中存在的名称。
基于MMRotate训练自定义数据集 做旋转目标检测 2022-3-30_YD-阿三的博客-CSDN博客_mmrotate
因为我是直接拉取AutoDL 的mmrotate的镜像,没有参考任何安装教程,新建镜像后新建虚拟环境直接pip install -r requirements.txt了,我于是往上看这篇博主的安装教程,发现自己少了一步:pip install -v -e .
于是抓紧运行这段代码,运行结果如下:
(mm) root@autodl-container-88b1118cac-9a2bde97:~/autodl-tmp/mmrotate# pip install -v -e .
Using pip 21.1.3 from /root/miniconda3/envs/mm/lib/python3.8/site-packages/pip (python 3.8)
Non-user install because site-packages writeable
Created temporary directory: /tmp/pip-ephem-wheel-cache-w5h6vt39
Created temporary directory: /tmp/pip-req-tracker-4_bg_fx2
Initialized build tracking at /tmp/pip-req-tracker-4_bg_fx2
Created build tracker: /tmp/pip-req-tracker-4_bg_fx2
Entered build tracker: /tmp/pip-req-tracker-4_bg_fx2
Created temporary directory: /tmp/pip-install-govquyod
Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple
Obtaining file:///root/autodl-tmp/mmrotate
Added file:///root/autodl-tmp/mmrotate to build tracker '/tmp/pip-req-tracker-4_bg_fx2'
Running setup.py (path:/root/autodl-tmp/mmrotate/setup.py) egg_info for package from file:///root/autodl-tmp/mmrotate
Created temporary directory: /tmp/pip-pip-egg-info-qysj1chj
Running command python setup.py egg_info
running egg_info
creating /tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info
writing /tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/dependency_links.txt
writing requirements to /tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/requires.txt
writing top-level names to /tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/SOURCES.txt'
listing git files failed - pretending there aren't any
reading manifest file '/tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'mmrotate/.mim/model-index.yml'
warning: no files found matching '*.py' under directory 'mmrotate/.mim/configs'
warning: no files found matching '*.yml' under directory 'mmrotate/.mim/configs'
warning: no files found matching '*.py' under directory 'mmrotate/.mim/tools'
warning: no files found matching '*.sh' under directory 'mmrotate/.mim/tools'
writing manifest file '/tmp/pip-pip-egg-info-qysj1chj/mmrotate.egg-info/SOURCES.txt'
Source in /root/autodl-tmp/mmrotate has version 0.3.4, which satisfies requirement mmrotate==0.3.4 from file:///root/autodl-tmp/mmrotate
Removed mmrotate==0.3.4 from file:///root/autodl-tmp/mmrotate from build tracker '/tmp/pip-req-tracker-4_bg_fx2'
Requirement already satisfied: e2cnn in ./src/e2cnn (from mmrotate==0.3.4) (0.2.3)
Requirement already satisfied: matplotlib in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (3.5.0)
Requirement already satisfied: mmcv-full in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (1.6.0)
Requirement already satisfied: mmdet<3.0.0,>=2.25.1 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (2.25.1)
Requirement already satisfied: numpy in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (1.21.4)
Requirement already satisfied: pycocotools in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (2.0.4)
Requirement already satisfied: six in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (1.16.0)
Requirement already satisfied: terminaltables in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (3.1.10)
Requirement already satisfied: torch in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmrotate==0.3.4) (1.10.0+cu113)
Requirement already satisfied: scipy in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from e2cnn->mmrotate==0.3.4) (1.9.0)
Requirement already satisfied: sympy in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from e2cnn->mmrotate==0.3.4) (1.11)
Requirement already satisfied: cycler>=0.10 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (0.11.0)
Requirement already satisfied: pillow>=6.2.0 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (8.4.0)
Requirement already satisfied: pyparsing>=2.2.1 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (3.0.6)
Requirement already satisfied: kiwisolver>=1.0.1 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (1.3.2)
Requirement already satisfied: fonttools>=4.22.0 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (4.28.2)
Requirement already satisfied: python-dateutil>=2.7 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (2.8.2)
Requirement already satisfied: setuptools-scm>=4 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (6.3.2)
Requirement already satisfied: packaging>=20.0 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from matplotlib->mmrotate==0.3.4) (21.3)
Requirement already satisfied: setuptools in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from setuptools-scm>=4->matplotlib->mmrotate==0.3.4) (52.0.0.post20210125)
Requirement already satisfied: tomli>=1.0.0 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from setuptools-scm>=4->matplotlib->mmrotate==0.3.4) (1.2.2)
Requirement already satisfied: addict in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmcv-full->mmrotate==0.3.4) (2.4.0)
Requirement already satisfied: pyyaml in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmcv-full->mmrotate==0.3.4) (6.0)
Requirement already satisfied: yapf in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmcv-full->mmrotate==0.3.4) (0.32.0)
Requirement already satisfied: opencv-python>=3 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from mmcv-full->mmrotate==0.3.4) (4.6.0.66)
Requirement already satisfied: mpmath>=0.19 in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from sympy->e2cnn->mmrotate==0.3.4) (1.2.1)
Requirement already satisfied: typing-extensions in /root/miniconda3/envs/mm/lib/python3.8/site-packages (from torch->mmrotate==0.3.4) (4.0.0)
Created temporary directory: /tmp/pip-unpack-a1zsp1ly
Installing collected packages: mmrotate
Attempting uninstall: mmrotate
Found existing installation: mmrotate 0.3.2
Uninstalling mmrotate-0.3.2:
Created temporary directory: /tmp/pip-uninstall-2yjeyrn6
Removing file or directory /root/miniconda3/envs/mm/lib/python3.8/site-packages/mmrotate.egg-link
Removing pth entries from /root/miniconda3/envs/mm/lib/python3.8/site-packages/easy-install.pth:
Removing entry: /root/mmrotate
Successfully uninstalled mmrotate-0.3.2
Running setup.py develop for mmrotate
Running command /root/miniconda3/envs/mm/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/root/autodl-tmp/mmrotate/setup.py'"'"'; __file__='"'"'/root/autodl-tmp/mmrotate/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
running develop
running egg_info
creating mmrotate.egg-info
writing mmrotate.egg-info/PKG-INFO
writing dependency_links to mmrotate.egg-info/dependency_links.txt
writing requirements to mmrotate.egg-info/requires.txt
writing top-level names to mmrotate.egg-info/top_level.txt
writing manifest file 'mmrotate.egg-info/SOURCES.txt'
listing git files failed - pretending there aren't any
reading manifest file 'mmrotate.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'mmrotate.egg-info/SOURCES.txt'
running build_ext
Creating /root/miniconda3/envs/mm/lib/python3.8/site-packages/mmrotate.egg-link (link to .)
Adding mmrotate 0.3.4 to easy-install.pth file
Installed /root/autodl-tmp/mmrotate
Successfully installed mmrotate-0.3.4
出现Successfully installed mmrotate-0.3.4,再次运行train.py,大功告成!