Skip to content

Commit b71c776

Browse files
author
Anna Grebneva
authored
AC: Added support for ssd-resnet-34-tf model (openvinotoolkit#3009)
* Added support for ssd-resnet-34-tf model * Updated readme
1 parent d4871dc commit b71c776

File tree

2 files changed

+22
-3
lines changed
  • tools/accuracy_checker/openvino/tools/accuracy_checker/adapters

2 files changed

+22
-3
lines changed

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,6 @@ AccuracyChecker supports following set of adapters:
489489
* `boxes_out` - name of output layer with bounding boxes coordinates.
490490
* `confidence_threshold` - lower bound for valid boxes scores (optional, default 0.01).
491491
* `nms_threshold` - overlap threshold for NMS (optional, default 0.45).
492-
* `keep_top_k ` - maximal number of boxes which should be kept (optional, default 200).
492+
* `keep_top_k` - maximal number of boxes which should be kept during NMS (optional, default 200).
493+
* `diff_coord_order` - ordering convention of coordinates differs from the commonly used format [x0, y0, x1, y1]. If value is True, the format of coordinates is [y0, x0, y1, x1] (optional, default False).
494+
* `max_detections` - maximal number of boxes which should be kept (optional).

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/ssd.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ def parameters(cls):
393393
'boxes_out': StringField(description='boxes output'),
394394
'confidence_threshold': NumberField(optional=True, default=0.01, description="confidence threshold"),
395395
'nms_threshold': NumberField(optional=True, default=0.45, description="NMS threshold"),
396-
'keep_top_k': NumberField(optional=True, value_type=int, default=200, description="keep top K")
396+
'keep_top_k': NumberField(optional=True, value_type=int, default=200, description="keep top K during NMS"),
397+
'diff_coord_order': BoolField(optional=True, default=False,
398+
description='Ordering convention of coordinates differs from standard'),
399+
'max_detections': NumberField(optional=True, value_type=int, description="maximal number of detections")
397400
})
398401
return params
399402

@@ -403,6 +406,8 @@ def configure(self):
403406
self.confidence_threshold = self.get_value_from_config('confidence_threshold')
404407
self.iou_threshold = self.get_value_from_config('nms_threshold')
405408
self.keep_top_k = self.get_value_from_config('keep_top_k')
409+
self.diff_coord_order = self.get_value_from_config('diff_coord_order')
410+
self.max_detections = self.get_value_from_config('max_detections')
406411
self.outputs_verified = False
407412

408413
def select_output_blob(self, outputs):
@@ -426,7 +431,10 @@ def process(self, raw, identifiers, frame_meta):
426431
continue
427432
subset_boxes = boxes[mask, :]
428433

429-
x_mins, y_mins, x_maxs, y_maxs = subset_boxes.T
434+
if self.diff_coord_order:
435+
y_mins, x_mins, y_maxs, x_maxs = subset_boxes.T
436+
else:
437+
x_mins, y_mins, x_maxs, y_maxs = subset_boxes.T
430438

431439
keep = NMS.nms(x_mins, y_mins, x_maxs, y_maxs, probs, self.iou_threshold, include_boundaries=False,
432440
keep_top_k=self.keep_top_k)
@@ -445,6 +453,15 @@ def process(self, raw, identifiers, frame_meta):
445453
detections['x_maxs'].extend(x_maxs)
446454
detections['y_maxs'].extend(y_maxs)
447455

456+
if self.max_detections:
457+
max_ids = np.argsort(-np.array(detections['scores']))[:self.max_detections]
458+
detections['labels'] = np.array(detections['labels'])[max_ids]
459+
detections['scores'] = np.array(detections['scores'])[max_ids]
460+
detections['x_mins'] = np.array(detections['x_mins'])[max_ids]
461+
detections['y_mins'] = np.array(detections['y_mins'])[max_ids]
462+
detections['x_maxs'] = np.array(detections['x_maxs'])[max_ids]
463+
detections['y_maxs'] = np.array(detections['y_maxs'])[max_ids]
464+
448465
result.append(DetectionPrediction(identifier, detections['labels'], detections['scores'],
449466
detections['x_mins'], detections['y_mins'], detections['x_maxs'],
450467
detections['y_maxs']))

0 commit comments

Comments
 (0)