0
votes

So I'm trying to retrain a fast_rcnn object detection model, with just one class, which I've attempted to run both locally (on a VM) and through ML engine. I keep running into the same error in regards to the train_config file however, which is an adaptation of the faster_rcnn_resnet50_coco.config configuration:

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _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", line 171, in tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 142, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 471, in train_and_evaluate return executor.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 637, in run getattr(self, task_to_run)() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 674, in run_master self._start_distributed_training(saving_listeners=saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/training.py", line 788, in _start_distributed_training saving_listeners=saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 354, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1207, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1234, in _train_model_default input_fn, model_fn_lib.ModeKeys.TRAIN)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1075, in _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 1162, in _call_input_fn return input_fn(**kwargs) File "/root/.local/lib/python2.7/site-packages/trainer/object_detection/inputs.py", line 375, in _train_input_fn raise TypeError('For training mode, the train_config must be a ' TypeError: For training mode, the train_config must be a train_pb2.TrainConfig.

I've spent a long time looking for the potential cause of this issue in my config file but I can't see what the problem is. There doesn't seem to be any documentation mentioning this apart from the TF source code itself. Any insight would be greatly appreciated!

    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
}
1

1 Answers

0
votes

I didn't see anything obviously wrong here. Could you do this for debugging:

add print type(configs['train_config']) and print configs['train_config'] to here

and let me know what are printed?