0

所以我试图重新训练一个 fast_rcnn 对象检测模型,只使用一个类,我试图在本地(在 VM 上)和通过 ML 引擎运行它。然而,关于 train_config 文件,我一直遇到同样的错误,这是对 faster_rcnn_resnet50_coco.config 配置的改编:

回溯(最后一次调用):文件“/usr/lib/python2.7/runpy.py”,第 174 行,在 _run_module_as_main “ main ”中", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages /trainer/task.py”,第 171 行,在 tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) 文件“/usr/local/lib/python2.7/dist- packages/tensorflow/python/platform/app.py”,第 125 行,在运行 _sys.exit(main(argv)) 文件“/root/.local/lib/python2.7/site-packages/trainer/task.py ”,第 142 行,在主 tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py”中,第 471 行,在 train_and_evaluate 返回 executor.run() 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py”,第 637 行,在运行 getattr(self, task_to_run)() 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py”,第 674 行,在 run_master self._start_distributed_training(saving_listeners=saving_listeners ) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py”,第 788 行,_start_distributed_training Saving_listeners=saving_listeners) 文件“/usr/local/lib/python2.7 /dist-packages/tensorflow/python/estimator/estimator.py”,第 354 行,在 train loss = self._train_model(input_fn, hooks, Saving_listeners) 文件“/usr/local/lib/python2.7/dist-packages/ tensorflow/python/estimator/estimator.py”,第 1207 行,在 _train_model 返回 self._train_model_default(input_fn, hooks, Saving_listeners) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py”,第 1234 行,在 _train_model_default input_fn, model_fn_lib.ModeKeys.TRAIN)) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/ python/estimator/estimator.py”,第 1075 行,在 _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py” ,第 1162 行,在 _call_input_fn 返回 input_fn(**kwargs) 文件“/root/.local/lib/python2.7/site-packages/trainer/object_detection/inputs.py”,第 375 行,在 _train_input_fn raise TypeError('For训练模式,7/dist-packages/tensorflow/python/estimator/estimator.py”,第 1075 行,在 _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/ python/estimator/estimator.py”,第 1162 行,在 _call_input_fn 返回 input_fn(**kwargs) 文件“/root/.local/lib/python2.7/site-packages/trainer/object_detection/inputs.py”,第 375 行, 在 _train_input_fn raise TypeError('对于训练模式,7/dist-packages/tensorflow/python/estimator/estimator.py”,第 1075 行,在 _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) 文件“/usr/local/lib/python2.7/dist-packages/tensorflow/ python/estimator/estimator.py”,第 1162 行,在 _call_input_fn 返回 input_fn(**kwargs) 文件“/root/.local/lib/python2.7/site-packages/trainer/object_detection/inputs.py”,第 375 行, 在 _train_input_fn raise TypeError('对于训练模式,第 375 行,在 _train_input_fn raise TypeError('对于训练模式,第 375 行,在 _train_input_fn raise TypeError('对于训练模式, train_config必须是 ' TypeError: 对于训练模式, train_config必须是 train_pb2.TrainConfig。

我花了很长时间在我的配置文件中寻找这个问题的潜在原因,但我看不出问题是什么。除了 TF 源代码本身之外,似乎没有任何文档提到这一点。任何见解将不胜感激!

    model {
  faster_rcnn {
    num_classes: 1
    image_resizer {
      fixed_shape_resizer {
        height: 600
        width: 205
      }
    }
    feature_extractor {
      type: 'faster_rcnn_resnet50'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: false
        dropout_keep_probability: 1.0
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
  }
}
train_config: {
  batch_size: 5
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        exponential_decay_learning_rate {
          initial_learning_rate: 0.0003
          decay_steps: 500
          decay_factor: 0.9
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "gs://ml-pipeline/checkpoints/fast_rcnn_resnet50/model.ckpt-5500"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  num_steps: 2000
  data_augmentation_options {
    normalize_image {
    }
    random_pixel_value_scale {
    }
    random_adjust_brightness {
    }
    random_jitter_boxes {
    }
    random_pad_image {
    }
  }
  max_number_of_boxes: 35
}
train_input_reader: {
  tf_record_input_reader {
    input_path: "gs://ml-pipeline/data/tf-records/train.record"
  }
  label_map_path: "gs://ml-pipeline/story_label_map.pbtxt"
}
eval_config {
  num_examples: 54
  num_visualizations: 54
  eval_interval_secs: 10
  max_evals: 1
  #use_moving_averages: false
}
eval_input_reader: {
  tf_record_input_reader {
    input_path: "gs://ml-pipeline/data/tf-records/test.record"
  }
  label_map_path: "gs://ml-pipeline/story_label_map.pbtxt"
  shuffle: false
  num_readers: 1
}
4

1 回答 1

0

我在这里没有看到任何明显的错误。你可以这样做调试:

此处添加print type(configs['train_config'])print configs['train_config']

让我知道打印了什么?

于 2019-03-21T19:19:26.293 回答