Commit 21ab9cf7 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower Committed by TF Object Detection Team
Browse files

Making NMS flag visible through ObjectDetectionEvaluator constructor. Note that

by default NMS is off.

PiperOrigin-RevId: 347613472
parent 690e44ed
......@@ -159,7 +159,9 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
metric_prefix=None,
use_weighted_mean_ap=False,
evaluate_masks=False,
group_of_weight=0.0):
group_of_weight=0.0,
nms_iou_threshold=1.0,
nms_max_output_boxes=10000):
"""Constructor.
Args:
......@@ -187,6 +189,8 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
matching_iou_threshold, weight group_of_weight is added to true
positives. Consequently, if no detection falls within a group-of box,
weight group_of_weight is added to false negatives.
nms_iou_threshold: NMS IoU threashold.
nms_max_output_boxes: maximal number of boxes after NMS.
Raises:
ValueError: If the category ids are not 1-indexed.
......@@ -202,6 +206,8 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
self._label_id_offset = 1
self._evaluate_masks = evaluate_masks
self._group_of_weight = group_of_weight
self._nms_iou_threshold = nms_iou_threshold
self._nms_max_output_boxes = nms_max_output_boxes
self._evaluation = ObjectDetectionEvaluation(
num_groundtruth_classes=self._num_classes,
matching_iou_threshold=self._matching_iou_threshold,
......@@ -209,7 +215,9 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
recall_upper_bound=self._recall_upper_bound,
use_weighted_mean_ap=self._use_weighted_mean_ap,
label_id_offset=self._label_id_offset,
group_of_weight=self._group_of_weight)
group_of_weight=self._group_of_weight,
nms_iou_threshold=self._nms_iou_threshold,
nms_max_output_boxes=self._nms_max_output_boxes)
self._image_ids = set([])
self._evaluate_corlocs = evaluate_corlocs
self._evaluate_precision_recall = evaluate_precision_recall
......@@ -454,7 +462,10 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
num_groundtruth_classes=self._num_classes,
matching_iou_threshold=self._matching_iou_threshold,
use_weighted_mean_ap=self._use_weighted_mean_ap,
label_id_offset=self._label_id_offset)
label_id_offset=self._label_id_offset,
nms_iou_threshold=self._nms_iou_threshold,
nms_max_output_boxes=self._nms_max_output_boxes,
)
self._image_ids.clear()
def add_eval_dict(self, eval_dict):
......@@ -549,13 +560,19 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
class PascalDetectionEvaluator(ObjectDetectionEvaluator):
"""A class to evaluate detections using PASCAL metrics."""
def __init__(self, categories, matching_iou_threshold=0.5):
def __init__(self,
categories,
matching_iou_threshold=0.5,
nms_iou_threshold=1.0,
nms_max_output_boxes=10000):
super(PascalDetectionEvaluator, self).__init__(
categories,
matching_iou_threshold=matching_iou_threshold,
evaluate_corlocs=False,
metric_prefix='PascalBoxes',
use_weighted_mean_ap=False)
use_weighted_mean_ap=False,
nms_iou_threshold=nms_iou_threshold,
nms_max_output_boxes=nms_max_output_boxes)
class WeightedPascalDetectionEvaluator(ObjectDetectionEvaluator):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment