mmdet
运行时提示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/utils/config.py", line 100, in _validate_py_syntax ast.parse(content) File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/ast.py", line 35, in parse return compile(source, filename, mode, PyCF_ONLY_AST) File "<unknown>", line 1 /home/ubuntu/bigdisk/part1/xxxx.py ^ SyntaxError: invalid syntax During handling of the above exception, another exception occurred: Traceback (most recent call last): File "train.py", line 171, in <module> main() File "train.py", line 167, in main meta=meta) File "/home/ubuntu/bigdisk/part1/test/xxx/tools/../mmdet/apis/train.py", line 111, in train_detector meta=meta) File "/home/ubuntu/bigdisk/part1/test/xxx/tools/../mmdet/apis/train.py", line 238, in _non_dist_train runner.resume(cfg.resume_from) File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/runner/base_runner.py", line 375, in resume checkpoint['meta']['config'], file_format='.py') File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/utils/config.py", line 344, in fromstring cfg = Config.fromfile(temp_file.name) File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/utils/config.py", line 316, in fromfile use_predefined_variables) File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/utils/config.py", line 204, in _file2dict Config._validate_py_syntax(filename) File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/site-packages/mmcv/utils/config.py", line 102, in _validate_py_syntax raise SyntaxError('There are syntax errors in config ' SyntaxError: There are syntax errors in config file /tmp/tmpaa48liz2.py: invalid syntax (<unknown>, line 1) Exception ignored in: <bound method _TemporaryFileCloser.__del__ of <tempfile._TemporaryFileCloser object at 0x7f57cc7e6c50>> Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/tempfile.py", line 452, in __del__ self.close() File "/home/ubuntu/anaconda3/envs/test/lib/python3.6/tempfile.py", line 448, in close unlink(self.name) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp3c8qqk_p/tmp1kje07dp.py' |
解决方法:
这种一般是两个原因:
1,转换模型的时候出现的问题,比如升级模型的时候,这时,只需要修改:
1 2 3 4 5 6 7 |
out_state_dict = OrderedDict() meta_info = checkpoint['meta'] is_two_stage, is_ssd, is_retina, reg_cls_agnostic = parse_config( meta_info['config']) if meta_info['mmdet_version'] <= '0.5.3' and is_retina: upgrade_retina = True else: |
将 meta_info['config'])
改成:'#' + meta_info['config'])
即可
2,mmcv
版本的问题
高版本的mmcv
会出现这个问题,只需要降级即可。
pip install mmcv==1.1.2
本文最后更新于2021年8月22日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!