tensorflow - tensorflow 物体检测:RFCN 模块的 MAP@0.5 相当低
问题描述
我使用 tensorflow 对象检测 api ( https://github.com/tensorflow/models/tree/master/research/object_detection ) 来训练一个 rfcn 模型,使用 voc 2007+2012 trainval 数据集,并在 voc 2007 测试中进行了测试。MAP@0.5 比 caffe 版本低很多。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
}
final result is: 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 /牛:0.790175 PascalBoxes_PerformanceByCategory/AP@0.5IOU/餐桌:0.483809 PascalBoxes_PerformanceByCategory/AP@0.5IOU/狗:0.819959 PascalBoxes_PerformanceByCategory/AP@0.5IOU/马:0.838640 PascalBoxes_PerformanceByCate:/@APIOU/bmotorikego.733901 PascalBoxes_PerformanceByCategory/AP@0.5IOU/person: 0.765344 PascalBoxes_PerformanceByCategory/AP@0.5IOU/pottedplant: 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.5 IOU/鸟:0.756 PascalBoxes_PerformanceByCategory/AP@0.5IOU/船:0.652 PascalBoxes_PerformanceByCategory/AP@0.5IOU/瓶:0.578 PascalBoxes_PerformanceByCategory/AP@0.5IOU/bus:0.843 PascalBoxes_PerformanceByCategory/AP@0.5IOU_PerformanceByCategory/AP@0.5IOU_PerformanceByCategory4 IOU/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.5借条/马:0。857 PascalBoxes_PerformanceByCategory/AP@0.5IOU/motorbike: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.746684 PascalBoxes_Precision/mAP@0.5IOU: 0.746684 PascalBoxes_Precision/mAP@0.5IOU: 0.746
解决方案
推荐阅读
- powerbi - 为什么措施不起作用:在power bi中更改策略编号时重新开始计数?
- windows - if/else 语句查看是否在特定窗口期间安装了 Windows 更新
- excel - 如何使用 VBA 加速 Excel 公式?
- c# - 如何将字符串从 C++ 原生传递到 C# Unity?
- python - 在 Seaborn 中设置默认饱和度
- java - 何时在 Cassandra 中使用 UUID 而不是毫秒时间戳?
- algorithm - 在 Python 上实现 Miller-Rabin 算法
- android - 如何检查android手机中是否可以使用显示在其他应用程序上的功能
- kubernetes - kubectl - 错误:您必须登录到服务器(服务器已要求客户端提供凭据)
- android-emulator - Android 模拟器 - 无法重置您设备上的状态