diff --git a/poetry.lock b/poetry.lock index 1ee8c59cd6..810c406c29 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2436,14 +2436,14 @@ numpy = {version = ">=2,<2.3.0", markers = "python_version >= \"3.9\""} [[package]] name = "openfoodfacts" -version = "3.3.0" +version = "3.4.0" description = "Official Python SDK of Open Food Facts" optional = false python-versions = ">=3.10" groups = ["main"] files = [ - {file = "openfoodfacts-3.3.0-py3-none-any.whl", hash = "sha256:cdca761569a17266a80d2e93bdc863090bfa51c1c5548c6c8582c3351abc24a3"}, - {file = "openfoodfacts-3.3.0.tar.gz", hash = "sha256:656dd98a4e620dc70899528359e75b7a773773cf8e420edcc352c31f5fa2aec1"}, + {file = "openfoodfacts-3.4.0-py3-none-any.whl", hash = "sha256:a50093e4285ab6e5e46bdc4e6702b68ee3961eff220485eb095108cc4d190db2"}, + {file = "openfoodfacts-3.4.0.tar.gz", hash = "sha256:532594916ea7dea5fc3328a31c4050cb866b66fa25893e5cc49444433fc0b6ff"}, ] [package.dependencies] @@ -5118,4 +5118,4 @@ watchdog = ["watchdog (>=2.3)"] [metadata] lock-version = "2.1" python-versions = "^3.11" -content-hash = "f07ca17ff16d89ee725fdbeae82be8f81b4acfffb5f0b78e0323069009a76e81" +content-hash = "4cb9c081b0a634586a0ec87aaf828b539ef74d1b98c778dbd653fb694c3cc420" diff --git a/pyproject.toml b/pyproject.toml index 789ff0eb1a..c0b7839b6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ lark = "~1.1.4" h5py = "~3.13.0" opencv-python-headless = "~4.12.0.88" toml = "~0.10.2" -openfoodfacts = "3.3.0" +openfoodfacts = "3.4.0" imagehash = "~4.3.1" peewee-migrate = "~1.12.2" diskcache = "~5.6.3" diff --git a/robotoff/app/api.py b/robotoff/app/api.py index 97a3146459..793b6c2bd1 100644 --- a/robotoff/app/api.py +++ b/robotoff/app/api.py @@ -809,7 +809,7 @@ def on_get(self, req: falcon.Request, resp: falcon.Response): "nms_threshold", default=None ) nms_eta: float | None = req.get_param_as_float("nms_eta", default=None) - + nms: bool = req.get_param_as_bool("nms", default=True) available_object_detection_models = list( ObjectDetectionModel.__members__.keys() ) @@ -868,6 +868,7 @@ def on_get(self, req: falcon.Request, resp: falcon.Response): threshold=threshold, nms_threshold=nms_threshold, nms_eta=nms_eta, + nms=nms, ) if output_image: diff --git a/robotoff/prediction/object_detection/core.py b/robotoff/prediction/object_detection/core.py index 5772b2d0c2..c5b2dd7534 100644 --- a/robotoff/prediction/object_detection/core.py +++ b/robotoff/prediction/object_detection/core.py @@ -92,6 +92,7 @@ class ModelConfig(BaseModel): triton_model_name="price_tag_detection", image_size=960, label_names=["price-tag"], + default_threshold=0.25, ), } @@ -110,6 +111,8 @@ def add_boxes_and_labels(image_array: np.ndarray, result: ObjectDetectionResult) instance_masks=None, use_normalized_coordinates=True, line_thickness=5, + max_boxes_to_draw=len(result.detection_boxes), + min_score_thresh=0.0, ) image_with_boxes = Image.fromarray(image_array) result.boxed_image = image_with_boxes @@ -127,6 +130,7 @@ def detect_from_image( threshold: float | None = None, nms_threshold: float | None = None, nms_eta: float | None = None, + nms: bool = True, ) -> ObjectDetectionResult: """Run an object detection model on an image. @@ -144,6 +148,7 @@ def detect_from_image( defaults to None (0.7 will be used). :param nms_eta: the NMS eta parameter to use, defaults to None (1.0 will be used). + :param nms: whether to use NMS, defaults to True. :return: the detection result """ threshold = threshold or self.config.default_threshold @@ -158,6 +163,7 @@ def detect_from_image( threshold=threshold, nms_threshold=nms_threshold, nms_eta=nms_eta, + nms=nms, ) for metric_name, duration in result.metrics.items(): ml_metrics_logger.info( diff --git a/tests/integration/insights/test_extraction.py b/tests/integration/insights/test_extraction.py index 26171acfa8..85da30a7ee 100644 --- a/tests/integration/insights/test_extraction.py +++ b/tests/integration/insights/test_extraction.py @@ -30,6 +30,7 @@ def detect_from_image( threshold: float | None = 0.5, nms_threshold: float | None = None, nms_eta: float | None = None, + nms: bool = True, ) -> ObjectDetectionResult: return self.raw_result