postprocessingdata.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:SSD_tensorflow_VOC 作者: LevinJ 项目源码 文件源码
def __compute_AP(self,c_scores,c_tp,c_fp,c_num_gbboxes):
        aps_voc07 = {}
        aps_voc12 = {}
        for c in c_scores.keys():
            num_gbboxes = c_num_gbboxes[c]
            tp = c_tp[c]
            fp = c_fp[c]
            scores = c_scores[c]

            #reshape data
            num_gbboxes = math_ops.to_int64(num_gbboxes)
            scores = math_ops.to_float(scores)
            stype = tf.bool
            tp = tf.cast(tp, stype)
            fp = tf.cast(fp, stype)
            # Reshape TP and FP tensors and clean away 0 class values.(difficult bboxes)
            scores = tf.reshape(scores, [-1])
            tp = tf.reshape(tp, [-1])
            fp = tf.reshape(fp, [-1])

            # Remove TP and FP both false.
            mask = tf.logical_or(tp, fp)

            rm_threshold = 1e-4
            mask = tf.logical_and(mask, tf.greater(scores, rm_threshold))
            scores = tf.boolean_mask(scores, mask)
            tp = tf.boolean_mask(tp, mask)
            fp = tf.boolean_mask(fp, mask)

            num_gbboxes = tf.reduce_sum(num_gbboxes)
            num_detections = tf.size(scores, out_type=tf.int32)

            # Precison and recall values.
            prec, rec = tfe.precision_recall(num_gbboxes, num_detections, tp, fp, scores)

            v = tfe.average_precision_voc07(prec, rec)
            aps_voc07[c] = v

            # Average precision VOC12.
            v = tfe.average_precision_voc12(prec, rec)

            aps_voc12[c] = v
        return aps_voc07, aps_voc12
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号