张量流对象检测:RFCN模块的MAP@0.5非常低

时间:2018-06-23 06:01:01

标签: tensorflow object-detection-api

我使用tensorflow对象检测api(https://github.com/tensorflow/models/tree/master/research/object_detection)使用voc 2007 + 2012 trainval数据集来训练rfcn模型,并在voc 2007测试中进行了测试。与caffe版本相比,MAP @ 0.5低得多。 caffe版本训练了110000次迭代,而Tensorflow版本训练了140000次迭代。经过预训练的resnet-v1-50模块,用于初始化主干特征提取器。配置文件如下:

#pascal_voc_resnet50_rfcn.config:
model {
  faster_rcnn {
    num_classes: 20
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_resnet50'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [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.0005
        }
      }
      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: 1.0
    first_stage_objectness_loss_weight: 1.0
    second_stage_box_predictor {
      rfcn_box_predictor {
        conv_hyperparams {
          op: CONV
          regularizer {
            l2_regularizer {
              weight: 0.0005
            }
          }
          initializer {
            truncated_normal_initializer {
              stddev: 0.01
            }
          }
        }
        crop_height: 18
        crop_width: 18
        num_spatial_bins_height: 3
        num_spatial_bins_width: 3
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.7
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 1.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.001
          schedule {
            step: 0
            learning_rate: .001
          }
          schedule {
            step: 900000
            learning_rate: .0001
          }
          schedule {
            step: 1200000
            learning_rate: .00001
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "resnet_v1_50/resnet_v1_50.ckpt"
  from_detection_checkpoint: false
  # 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: 1500000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}

train_input_reader: {
  tf_record_input_reader {
    input_path: "voc_dataset/trainval.tfrecords"
  }
  label_map_path: "object_detection/data/pascal_label_map.pbtxt"
}

eval_config: {
#  num_examples: 8000
  num_examples: 4952
  num_visualizations: 4952
  # Note: The below line limits the evaluation process to 10 evaluations.
  # Remove the below line to evaluate indefinitely.
  max_evals: 1
  visualization_export_dir: 'outputs_eval_imgs'
  metrics_set: 'pascal_voc_metrics'
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "voc_dataset/test.tfrecords"
  }
  label_map_path: "object_detection/data/pascal_label_map.pbtxt"
  shuffle: false
  num_readers: 1
  num_epochs: 1
}

最终结果是: PascalBoxes_PerformanceByCategory/AP@0.5IOU/aeroplane:0.701776 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bicycle:0.742742 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bird:0.723409 PascalBoxes_PerformanceByCategory/AP@0.5IOU/boat:0.513328 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bottle:0.531051 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bus:0.769170 PascalBoxes_PerformanceByCategory/AP@0.5IOU/car:0.811411 PascalBoxes_PerformanceByCategory/AP@0.5IOU/cat:0.831349 PascalBoxes_PerformanceByCategory/AP@0.5IOU/chair:0.472102 PascalBoxes_PerformanceByCategory/AP@0.5IOU/cow:0.790175 PascalBoxes_PerformanceByCategory/AP@0.5IOU/diningtable:0.483809 PascalBoxes_PerformanceByCategory/AP@0.5IOU/dog:0.819959 PascalBoxes_PerformanceByCategory/AP@0.5IOU/马:0.838640 PascalBoxes_PerformanceByCategory/AP@0.5IOU/motor:0.733901 PascalBoxes_PerformanceByCategory/AP@0.5IOU/人:0.765344 PascalBoxes_PerformanceByCategory/AP@0.5IOU/盆栽植物:0.379224 PascalBoxes_PerformanceByCategory/AP@0.5IOU/sheep:0.719418 PascalBoxes_PerformanceByCategory/AP@0.5IOU/sofa:0.576437 PascalBoxes_PerformanceByCategory/AP@0.5IOU/train:0.726485 PascalBoxes_PerformanceByCategory/AP@0.5IOU/tvmonitor:0.683094 PascalBoxes_Precision/mAP@0.5IOU:0.680641

但是,当我使用原始版本(基于caffe)时,mAP为0.746,详细信息如下: PascalBoxes_PerformanceByCategory/AP@0.5IOU/aeroplane:0.781 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bicycle:0.793 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bird:0.756 PascalBoxes_PerformanceByCategory/AP@0.5IOU/boat:0.652 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bottle:0.578 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bus:0.843 PascalBoxes_PerformanceByCategory/AP@0.5IOU/car:0.846 PascalBoxes_PerformanceByCategory/AP@0.5IOU/cat:0.889 PascalBoxes_PerformanceByCategory/AP@0.5IOU/chair:0.565 PascalBoxes_PerformanceByCategory/AP@0.5IOU/cow:0.835 PascalBoxes_PerformanceByCategory/AP@0.5IOU/diningtable:0.658 PascalBoxes_PerformanceByCategory/AP@0.5IOU/dog:0.867 PascalBoxes_PerformanceByCategory/AP@0.5IOU/马:0.857 PascalBoxes_PerformanceByCategory/AP@0.5IOU/motor:0.792 PascalBoxes_PerformanceByCategory/AP@0.5IOU/person:0.778 PascalBoxes_PerformanceByCategory/AP@0.5IOU/pottedplant:0.412 PascalBoxes_PerformanceByCategory/AP@0.5IOU/sheep:0.757 PascalBoxes_PerformanceByCategory/AP@0.5IOU/sofa:0.723 PascalBoxes_PerformanceByCategory/AP@0.5IOU/train:0.846 PascalBoxes_PerformanceByCategory/AP@0.5IOU/tvmonitor:0.684 PascalBoxes_Precision/mAP@0.5IOU:0.746

0 个答案:

没有答案