From ce87dca1d7336a46747bf32645b93712c95d0606 Mon Sep 17 00:00:00 2001 From: NielsRogge <48327001+NielsRogge@users.noreply.github.com> Date: Mon, 13 May 2024 16:47:58 +0200 Subject: [PATCH] [Object detection pipeline] Lower threshold (#30710) * Lower threshold * Address comment --- src/transformers/pipelines/object_detection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/pipelines/object_detection.py b/src/transformers/pipelines/object_detection.py index d6ae63f4bd..36946cbf8a 100644 --- a/src/transformers/pipelines/object_detection.py +++ b/src/transformers/pipelines/object_detection.py @@ -83,7 +83,7 @@ class ObjectDetectionPipeline(Pipeline): The pipeline accepts either a single image or a batch of images. Images in a batch must all be in the same format: all as HTTP(S) links, all as local paths, or all as PIL images. - threshold (`float`, *optional*, defaults to 0.9): + threshold (`float`, *optional*, defaults to 0.5): The probability necessary to make a prediction. timeout (`float`, *optional*, defaults to None): The maximum time in seconds to wait for fetching images from the web. If None, no timeout is set and @@ -120,7 +120,7 @@ class ObjectDetectionPipeline(Pipeline): model_outputs["bbox"] = model_inputs["bbox"] return model_outputs - def postprocess(self, model_outputs, threshold=0.9): + def postprocess(self, model_outputs, threshold=0.5): target_size = model_outputs["target_size"] if self.tokenizer is not None: # This is a LayoutLMForTokenClassification variant.