保存训练模型文件时的Detectron错误

时间:2018-02-07 13:50:34

标签: python caffe2

我正在使用以下命令训练Detectron

python2 tools / train_net.py \     --cfg configs / getting_started / tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml \     OUTPUT_DIR / tmp / detectron-output

我收到以下错误。一切顺利,除了在即将保存训练模型文件的最后。

提前感谢您的帮助。

...........

 File "/home/username/Documents/Detectron/lib/utils/net.py", line 165, in save_model_to_weights_file
    cfg_yaml = yaml.dump(cfg)
  File "build/bdist.linux-x86_64/egg/yaml/__init__.py", line 202, in dump
  File "build/bdist.linux-x86_64/egg/yaml/__init__.py", line 190, in dump_all
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 28, in represent
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 61, in represent_data
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 447, in represent_object
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 123, in represent_mapping
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 57, in represent_data
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 223, in represent_dict
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 123, in represent_mapping
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 41, in represent_data
  File "build/bdist.linux-x86_64/egg/yaml/representer.py", line 142, in ignore_aliases
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

2 个答案:

答案 0 :(得分:0)

这是我的.yaml文件:

MODEL:
  TYPE: generalized_rcnn
  CONV_BODY: FPN.add_fpn_ResNet50_conv5_body
  NUM_CLASSES: 81
  FASTER_RCNN: True
NUM_GPUS: 1
SOLVER:
  WEIGHT_DECAY: 0.0001
  LR_POLICY: steps_with_decay
  BASE_LR: 0.0025
  GAMMA: 0.1
  MAX_ITER: 100
  STEPS: [0, 30, 40]
FPN:
  FPN_ON: True
  MULTILEVEL_ROIS: True
  MULTILEVEL_RPN: True
FAST_RCNN:
  ROI_BOX_HEAD: fast_rcnn_heads.add_roi_2mlp_head
  ROI_XFORM_METHOD: RoIAlign
  ROI_XFORM_RESOLUTION: 7
  ROI_XFORM_SAMPLING_RATIO: 2
TRAIN:
  WEIGHTS: R-50.pkl
  DATASETS: ('mydata_2018_train',)
  SCALES: (500,)
  MAX_SIZE: 833
  BATCH_SIZE_PER_IM: 256
  RPN_PRE_NMS_TOP_N: 2000  # Per FPN level
TEST:
  DATASETS: ('mydata_2018_test',)
  SCALES: (500,)
  MAX_SIZE: 833
  NMS: 0.5
  RPN_PRE_NMS_TOP_N: 1000  # Per FPN level
  RPN_POST_NMS_TOP_N: 1000
OUTPUT_DIR: .

答案 1 :(得分:0)

我遇到了同样的问题。安装较新的PyYAML,如建议的here,为我解决了这个问题:

pip install 'pyyaml>=3.12'