错误yaml.constructor.ConstructorError: could not determine a constructor for the tag
错误提示:
Traceback (most recent call last):
File "tools/train_net.py", line 133, in <module>
main()
File "tools/train_net.py", line 98, in main
if args.cfg_file is not None:
File "/data/yang/detectron/detectron/utils/train.py", line 58, in train_model
setup_model_for_training(model, weights_file, output_dir)
File "/data/yang/detectron/detectron/utils/train.py", line 174, in setup_model_for_training
nu.initialize_gpu_from_weights_file(model, weights_file, gpu_id=0)
File "/data/yang/detectron/detectron/utils/net.py", line 65, in initialize_gpu_from_weights_file
saved_cfg = load_cfg(src_blobs['cfg'])
File "/data/yang/detectron/detectron/core/config.py", line 1147, in load_cfg
return envu.yaml_load(cfg_to_load)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 51, in get_single_data
return self.construct_document(node)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 55, in construct_document
data = self.construct_object(node)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 102, in construct_object
data = constructor(self, tag_suffix, node)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 659, in construct_python_object_new
return self.construct_python_object_apply(suffix, node, newobj=True)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 642, in construct_python_object_apply
value = self.construct_mapping(node, deep=True)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 218, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 143, in construct_mapping
value = self.construct_object(value_node, deep=deep)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 107, in construct_object
for dummy in generator:
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
value = self.construct_mapping(node)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 218, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 143, in construct_mapping
value = self.construct_object(value_node, deep=deep)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 100, in construct_object
data = constructor(self, node)
File "/home/ec2-user/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/yaml/constructor.py", line 429, in construct_undefined
node.start_mark)
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/apply:numpy.core.multiarray.scalar'
in "<unicode string>", line 3, column 20:
BBOX_XFORM_CLIP: !!python/object/apply:numpy.core ...
错误原因分析:
pyyaml的版本不匹配造成的。
解决方法:
(1)卸载之前的版本
conda list
conda remove pyyaml
conda remove yaml
(2)安装此版本的yaml
pip install pyyaml==4.2b2
至此问题完美解决!!!
参考链接: