GCP中的训练对象检测终止于:TypeError:预期的二进制或Unicode字符串,获取为None

时间:2019-02-27 07:49:38

标签: python-3.x tensorflow machine-learning google-cloud-platform

我们正在尝试提交有关GCP的培训工作。我遵循了宠物教程,走了很远,但是现在我有点卡住了,希望有人能指出我正确的方向。

我们正在使用以下命令开始培训工作:

gcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s`  \
    --job-dir=${YOUR_GCS_BUCKET}/train \
    --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
    --module-name object_detection.model_main \
    --runtime-version 1.11 \
    --region europe-west1 \
    --python-version 3.5

该作业已成功排队,并显示在ML Engine任务概述中。出现许多日志,看起来都很正确,直到实际开始培训工作为止。然后出现错误(下面的日志中的第3行)。我将日志的最后几行放在下面:

2019-02-26 16:03:42.994 CET master-replica-0 Running command: python3 -m object_detection.model_main --job-dir gs://tiotf_train_store/train
2019-02-26 16:04:01.119 CET master-replica-0 TF_CONFIG environment variable: {'environment': 'cloud', 'task': {'type': 'master', 'index': 0, 'cloud': 'sd5078b2935497c61-ml'}, 'job': {'runtime_version': '1.11', 'python_module': 'object_detection.model_main', 'package_uris': ['gs://tiotf_train_store/train/packages/4ce59656c997bb99dded0300dd801c07db79e589aee2d33fd2cc15b844d27c96/object_detection-0.1.tar.gz', 'gs://tiotf_train_store/train/packages/4ce59656c997bb99dded0300dd801c07db79e589aee2d33fd2cc15b844d27c96/slim-0.1.tar.gz', 'gs://tiotf_train_store/train/packages/4ce59656c997bb99dded0300dd801c07db79e589aee2d33fd2cc15b844d27c96/pycocotools-2.0.tar.gz'], 'region': 'europe-west1', 'job_dir': 'gs://tiotf_train_store/train', 'run_on_raw_vm': True, 'python_version': '3.5'}, 'cluster': {'master': ['127.0.0.1:2222']}}
2019-02-26 16:04:01.156 CET master-replica-0 Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/root/.local/lib/python3.5/site-packages/object_detection/model_main.py", line 109, in <module> tf.app.run() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "/root/.local/lib/python3.5/site-packages/object_detection/model_main.py", line 71, in main FLAGS.sample_1_of_n_eval_on_train_examples)) File "/root/.local/lib/python3.5/site-packages/object_detection/model_lib.py", line 566, in create_estimator_and_inputs config_override=config_override) File "/root/.local/lib/python3.5/site-packages/object_detection/utils/config_util.py", line 95, in get_configs_from_pipeline_file proto_str = f.read() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 125, in read self._preread_check() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 85, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/compat.py", line 61, in as_bytes (bytes_or_text,)) TypeError: Expected binary or unicode string, got None
2019-02-26 16:04:01.623 CET master-replica-0 Command '['python3', '-m', 'object_detection.model_main', '--job-dir', 'gs://tiotf_train_store/train']' returned non-zero exit status 1

有人可以指出我在哪里寻找可能的解决方案吗?所有数据都存在于上述子存储区的数据子文件夹中。 我还将配置文件放在存储桶中(名为faster_rcnn_resnet101_pets.config)

model {
  faster_rcnn {
    num_classes: 37
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_resnet101'
      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: 1
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        manual_step_learning_rate {
          initial_learning_rate: 0.0003
          schedule {
            step: 900000
            learning_rate: .00003
          }
          schedule {
            step: 1200000
            learning_rate: .000003
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "gs://tiotf_train_store/data/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets dataset. This
  # effectively bypasses the learning rate schedule (the learning rate will
  # never decay). Remove the below line to train indefinitely.
  num_steps: 200000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}

train_input_reader: {
  tf_record_input_reader {
    input_path: "gs://tiotf_train_store/data/pet_faces_train.record-?????-of-00010"
  }
  label_map_path: "gs://tiotf_train_store/data/pet_label_map.pbtxt"
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  num_examples: 1101
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "gs://tiotf_train_store/data/pet_faces_val.record-?????-of-00010"
  }
  label_map_path: "gs://tiotf_train_store/data/pet_label_map.pbtxt"
  shuffle: false
  num_readers: 1
}

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

经过数小时的尝试,我认为我找到了问题。在gcloud命令中添加了以下参数:

-- 
--pipeline_config_path=[path to .config file]

现在,培训工作可以正确开始了。