【问题标题】:What does tensorflow object detection max proposals mean exactly?tensorflow object detection max proposal 到底是什么意思?
【发布时间】:2018-08-13 21:57:45
【问题描述】:

我正在尝试准确理解 tensorflow 对象检测配置字段。

根据这篇文章(https://medium.com/@jonathan_hui/object-detection-speed-and-accuracy-comparison-faster-r-cnn-r-fcn-ssd-and-yolo-5425656ae359),为了在准确性和速度之间取得良好的平衡,我将 first_stage_max_proposals 从 origin 100 更改为 50。

好消息是,它确实减少了推理延迟(从每张图像 4.2 秒到 2.2 秒),但坏消息是它也降低了准确性。

然后,我将最大提案从 50 更改为 70,准确性更好。

所以,我想确切地知道最大提案控制的内容。它是否与任何其他配置有关,例如 max_detections_per_class 或 max_total_detections .etc?

我在谷歌上搜索了很多,但似乎对这个人不太感兴趣。 我使用 python3.6.4 和 tensorflow 1.8.0,这是我的模型配置:

model {
  faster_rcnn {
    num_classes: 3
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension:  670
        max_dimension: 1013
      }
    }
    feature_extractor {
      type: "faster_rcnn_resnet101"
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        height_stride: 16
        width_stride: 16
        scales: 0.25
        scales: 0.5
        scales: 1.0
        scales: 2.0
        aspect_ratios: 0.5
        aspect_ratios: 1.0
        aspect_ratios: 2.0
      }
    }
    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: 70
    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 {
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
        use_dropout: false
        dropout_keep_probability: 1.0
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.3
        iou_threshold: 0.6
        max_detections_per_class: 30
        max_total_detections: 30
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
    second_stage_batch_size: 70
  }
}
train_config {
  batch_size: 1
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  optimizer {
    momentum_optimizer {
      learning_rate {
        exponential_decay_learning_rate {
          initial_learning_rate: 0.0003
          decay_steps: 2000
          decay_factor: 0.95
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "d:/od/tool/faster_rcnn3/model.ckpt"
  from_detection_checkpoint: true
}
train_input_reader {
  label_map_path: "d:/od/project/train_allinone/file/labelmap.pbtxt"
  tf_record_input_reader {
    input_path: "d:/od/project/train_allinone/file/tf.record"
  }
}

对此的任何解释都非常感谢。

谢谢。

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    看着faster_rcnn.proto

    // Naming conventions:
    // Faster R-CNN models have two stages: a first stage region proposal network
    // (or RPN) and a second stage box classifier.  We thus use the prefixes
    // `first_stage_` and `second_stage_` to indicate the stage to which each
    // parameter pertains when relevant
    

    所以:

    // Maximum number of RPN proposals retained after first stage postprocessing.
    optional int32 first_stage_max_proposals = 15 [default=300];
    

    Faster R-CNN 有两个网络,第一个提出可以找到对象的区域,第二个尝试检测其中的对象。增加第一个网络的提案数量会提高准确性,但意味着更多的计算工作,因为第二个网络必须在更多潜在区域中进行搜索。有关 Faster R-CNN 工作原理的快速说明,请查看Faster R-CNN Explained,如果您想了解完整的图片,可以查看原始出版物:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks

    【讨论】:

    • 是的,因此,如文档中所述,first_stage_max_proposals 越大,准确性越高,推理延迟也越大。所以,现在我的目的是在准确性和推理速度之间取得良好的平衡,因此,最好将建议设置得尽可能小。就是不知道这个人是不是和其他的配置域有关系,也就是说其他的配置域做完了,我们可以把proposals设置成一个小值,没必要设置成更大的值
    • @Wesley 好吧,肯定有所有其他参数的相互作用。我的意思是,如果第一阶段网络更大,人们会期望它找到“更高质量”的提案,因此您可以将它们保持在较低的数量,但这反过来会使第一阶段的训练和运行速度变慢。我不认为你可以找到参数之间容易表达的关系,这可能更多是超参数优化的问题......
    猜你喜欢
    • 2020-06-16
    • 2017-08-07
    • 2017-07-20
    • 2014-09-23
    • 2014-07-25
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多