Tensorflow Object Detection API 训练Faster RCNN遇到的问题

在使用框架ssd_mobilenet_v1_coco_2017_11_17训练自己的数据集成功之后,我想要试试在Faster RCNN框架上训练自己数据集。

流程与使用SSD大致相同

  1. 数据集生成train.record和test.record
  2. 然后在training文件夹下创建faster_rcnn_inception_resnet_v2_atrous_coco.config, 下载地址
    修改里面的num_class和对应的path即可。

注意:training文件夹里面如果包含了上一次使用SSD训练生成的大量ckpt文件,必须删除,不然会报错:Key Conv/biases not found in checkpoint。即:留下一个干干净净的training文件夹,只含faster_rcnn_inception_resnet_v2_atrous_coco.config

Tensorflow Object Detection API 训练Faster RCNN遇到的问题_第1张图片


  1. 开始训练:
    cmd下:object_detection>> python train.py –logtostderr –train_dir=training/ –pipeline_config_path=training/faster_rcnn_inception_resnet_v2_atrous_coco.config

此时可能会报错:ValueError: Tried to convert ‘t’ to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [](这个错误可能是python的版本兼容性问题)

解决办法:参考来源
即:找到models/research/object_detection/utils/learning_schedules.py 中的167-169行,rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
range(num_boundaries),
[0] * num_boundaries))
改成:
rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),
list(range(num_boundaries)),
[0] * num_boundaries))


以防万一,我在此处还对 protobufs重新编译了一次,
即在/models/research/下运行
protoc object_detection/protos/*.proto –python_out=.


也有人指出是因为config更新做出了一些改动,但是我在这里的faster_rcnn_inception_resnet_v2_atrous_coco.config是从官网直接复制下来的,已经是最新的了,不需要改动。
Tensorflow Object Detection API 训练Faster RCNN遇到的问题_第2张图片

你可能感兴趣的:(Tensorflow Object Detection API 训练Faster RCNN遇到的问题)