Skip to content

Commit

Permalink
Fix detection tiler to support iseg
Browse files Browse the repository at this point in the history
  • Loading branch information
sovrasov committed Jul 4, 2023
1 parent e1c69be commit 8cd7acf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions model_api/python/openvino/model_api/tilers/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def parameters(cls):
)
return parameters

def _postprocess_tile(self, predictions, meta):
def _postprocess_tile(self, predictions, coord):
"""Converts predictions to a format convinient for further merging.
Args:
predictions: predictions from a detection model: a list of `Detection` objects
or one `DetectionResult`
meta: a dict containing key "coord", representing tile coordinates
coord: a list containing coordinates for the processed tile
Returns:
a dict with postprocessed predictions in 6-items format: (label id, score, bbox)
Expand All @@ -67,15 +67,18 @@ def _postprocess_tile(self, predictions, meta):
output_dict = {}
if hasattr(predictions, "objects"):
detections = _detection2array(predictions.objects)
output_dict["saliency_map"] = predictions.saliency_map
output_dict["features"] = predictions.feature_vector
elif hasattr(predictions, "segmentedObjects"):
detections = _detection2array(predictions.segmentedObjects)
else:
detections = _detection2array(predictions)
raise RuntimeError("Unsupported model predictions fromat")

offset_x, offset_y = meta["coord"][:2]
output_dict["saliency_map"] = predictions.saliency_map
output_dict["features"] = predictions.feature_vector

offset_x, offset_y = coord[:2]
detections[:, 2:] += np.tile((offset_x, offset_y), 2)
output_dict["bboxes"] = detections
output_dict["coords"] = meta["coord"]
output_dict["coords"] = coord

return output_dict

Expand Down

0 comments on commit 8cd7acf

Please sign in to comment.