我对在Tensorflow的对象检测库中验证数据集运行验证图像并获得损失(类似于训练期间的损失)感兴趣 .
我正在尝试修改evaluateator.py(https://github.com/tensorflow/models/blob/master/object_detection/evaluator.py#L38)中的_extract_prediction_tensors函数,如下所示 . 我正在向tensor_dict添加一个丢失字典,以便评估损失 .
groundtruth_boxes_list =
[input_dict[fields.InputDataFields.groundtruth_boxes]]
label_id_offset = 1
groundtruth_classes_list =
tf.cast(input_dict[fields.InputDataFields.groundtruth_classes],
tf.int32)
groundtruth_classes_list -= label_id_offset
groundtruth_classes_list =
[ops.padded_one_hot_encoding(indices=groundtruth_classes_list,
depth=model.num_classes, left_pad=0)]
model.provide_groundtruth(groundtruth_boxes_list,
groundtruth_classes_list)
losses_dict = model.loss(prediction_dict)
tensor_dict['loss'] = losses_dict
但是我得到的分类损失是错误的,即使我可以看到它已经正确分类 . 不确定实现中是否仍有错误 .
1 回答
损失已由评估脚本计算 . 我目前正在用几行代码提取它 . 这样做的方法是修改文件“/models/research/object_detection/eval_util.py” . 在行中的repeated_checkpoint_run()中:
这里的“指标”是一个包含所有类AP以及所有损失的字典 . 要提取它们,请添加这些新行(缩进为上一行):
这些值应该是您在配置文件中设置的评估数据的mAP,本地化和分类丢失 .