diff --git a/nuclio_lighting_flash/nuclio_detection_labels_output.py b/nuclio_lighting_flash/nuclio_detection_labels_output.py index 53c0367..3246ae5 100644 --- a/nuclio_lighting_flash/nuclio_detection_labels_output.py +++ b/nuclio_lighting_flash/nuclio_detection_labels_output.py @@ -60,10 +60,10 @@ def transform(self, sample: Dict[str, Any]) -> List[Dict[str, Any]]: # the actual image size, "self.image_width", " self.image_height". # This is why we "/ width * self.image_width" etc box = [ - bbox["xmin"] / width * self.image_width, - bbox["ymin"] / height * self.image_height, - (bbox["xmin"] + bbox["width"]) / width * self.image_width, - (bbox["ymin"] + bbox["height"]) / height * self.image_height, + round(bbox["xmin"] / width * self.image_width, 2), + round(bbox["ymin"] / height * self.image_height, 2), + round((bbox["xmin"] + bbox["width"]) / width * self.image_width, 2), + round((bbox["ymin"] + bbox["height"]) / height * self.image_height, 2), ] label = label.item() @@ -74,7 +74,7 @@ def transform(self, sample: Dict[str, Any]) -> List[Dict[str, Any]]: detections.append( { - "confidence": confidence, + "confidence": round(confidence, 2), "label": label, "points": box, "type": "rectangle", diff --git a/nuclio_lighting_flash/test_main.py b/nuclio_lighting_flash/test_main.py index 63d4b4a..1cb3538 100644 --- a/nuclio_lighting_flash/test_main.py +++ b/nuclio_lighting_flash/test_main.py @@ -17,25 +17,15 @@ def test_main(): assert response.body == json.dumps( [ { - "confidence": 0.9171872138977051, + "confidence": 0.92, "label": "giraffe", - "points": [ - 372.63145446777344, - 114.83981323242188, - 601.5438079833984, - 315.83863592147827, - ], + "points": [372.63, 114.84, 601.54, 315.84], "type": "rectangle", }, { - "confidence": 0.8744097352027893, + "confidence": 0.87, "label": "giraffe", - "points": [ - 52.77256488800049, - 305.4035350084305, - 185.64495086669922, - 349.67146718502045, - ], + "points": [52.77, 305.4, 185.64, 349.67], "type": "rectangle", }, ]