【发布时间】:2019-01-09 20:30:06
【问题描述】:
我正在使用此存储库,其基本代码 (https://github.com/ndaidong/tf-object-detection) 使用 Tensorflow 对象检测来检测评论屏幕截图中的评论、日期、喜欢和评分。
我浏览了 100 张图片(只是想测试这是否可行),用 4 个标签(评论、日期、喜欢和评分)对图片进行注释,从 XML 转换为 CSV,然后生成 TFrecords。这是为训练和评估数据完成的。 100 幅图像用于训练,20 幅图像用于评估。这是我注释的内容的屏幕截图。 Click here for an example of the annotated image
为了训练,我使用了以下配置
model {
ssd {
num_classes: 4
image_resizer {
fixed_shape_resizer {
height: 500
width: 2000
}
}
feature_extractor {
type: "ssd_mobilenet_v2"
depth_multiplier: 1.0
min_depth: 16
conv_hyperparams {
regularizer {
l2_regularizer {
weight: 3.99999989895e-05
}
}
initializer {
truncated_normal_initializer {
mean: 0.0
stddev: 0.0299999993294
}
}
activation: RELU_6
batch_norm {
decay: 0.999700009823
center: true
scale: true
epsilon: 0.0010000000475
train: true
}
}
use_depthwise: true
}
box_coder {
faster_rcnn_box_coder {
y_scale: 10.0
x_scale: 10.0
height_scale: 5.0
width_scale: 5.0
}
}
matcher {
argmax_matcher {
matched_threshold: 0.5
unmatched_threshold: 0.5
ignore_thresholds: false
negatives_lower_than_unmatched: true
force_match_for_each_row: true
}
}
similarity_calculator {
iou_similarity {
}
}
box_predictor {
convolutional_box_predictor {
conv_hyperparams {
regularizer {
l2_regularizer {
weight: 3.99999989895e-05
}
}
initializer {
truncated_normal_initializer {
mean: 0.0
stddev: 0.0299999993294
}
}
activation: RELU_6
batch_norm {
decay: 0.999700009823
center: true
scale: true
epsilon: 0.0010000000475
train: true
}
}
min_depth: 0
max_depth: 0
num_layers_before_predictor: 0
use_dropout: false
dropout_keep_probability: 0.800000011921
kernel_size: 3
box_code_size: 4
apply_sigmoid_to_scores: false
}
}
anchor_generator {
ssd_anchor_generator {
num_layers: 6
min_scale: 0.20000000298
max_scale: 0.949999988079
aspect_ratios: 1.0
aspect_ratios: 2.0
aspect_ratios: 0.5
aspect_ratios: 3.0
aspect_ratios: 0.333299994469
}
}
post_processing {
batch_non_max_suppression {
score_threshold: 0.300000011921
iou_threshold: 0.600000023842
max_detections_per_class: 100
max_total_detections: 100
}
score_converter: SIGMOID
}
normalize_loss_by_num_matches: true
loss {
localization_loss {
weighted_smooth_l1 {
}
}
classification_loss {
weighted_sigmoid {
}
}
hard_example_miner {
num_hard_examples: 3000
iou_threshold: 0.990000009537
loss_type: CLASSIFICATION
max_negatives_per_positive: 3
min_negatives_per_image: 3
}
classification_weight: 1.0
localization_weight: 1.0
}
}
}
train_config {
batch_size: 35
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
ssd_random_crop {
}
}
optimizer {
rms_prop_optimizer {
learning_rate {
exponential_decay_learning_rate {
initial_learning_rate: 0.00400000018999
decay_steps: 800720
decay_factor: 0.949999988079
}
}
momentum_optimizer_value: 0.899999976158
decay: 0.899999976158
epsilon: 1.0
}
}
num_steps: 200
}
train_input_reader: {
tf_record_input_reader {
input_path: "temp/data/train.record"
}
label_map_path: "configs/reviews/labels.pbtxt"
}
eval_config {
num_examples: 20
max_evals: 10
use_moving_averages: false
}
eval_input_reader: {
tf_record_input_reader {
input_path: "temp/data/test.record"
}
label_map_path: "configs/reviews/labels.pbtxt"
shuffle: false
num_readers: 1
}
如您所见,我正在尝试从头开始训练数据,而不是使用现有模型。这样做的原因是因为我不是试图找到已经训练过的一般对象。
我调整了 fixed_shape_resizer,因为评论的图像尺寸大约是 2000 宽和 500 高。
我只使用了 200 步进行训练(我需要做更多吗?),正如我在 Tensorboard 中注意到的,在 100 步后它开始学习,因为“损失”结果开始下降很多. Click here to see Tensorboard results
但是,当我导出/冻结图表然后尝试预测时。什么都无法预测。在我看来一切都很好。我做错了吗?
【问题讨论】:
-
仅 200 张图像就足以进行对象检测,至少对于测试而言。你可能做错了一些步骤,参考pythonprogramming.net/…
标签: python tensorflow machine-learning object-detection