diff --git a/inference/core/workflows/core_steps/formatters/vlm_as_detector/v2.py b/inference/core/workflows/core_steps/formatters/vlm_as_detector/v2.py index 23fad45a8a..7ce8f42933 100644 --- a/inference/core/workflows/core_steps/formatters/vlm_as_detector/v2.py +++ b/inference/core/workflows/core_steps/formatters/vlm_as_detector/v2.py @@ -291,7 +291,14 @@ def create_classes_index(classes: List[str]) -> Dict[str, int]: def scale_confidence(value: float) -> float: - return min(max(float(value), 0.0), 1.0) + # Fast path: avoid redundant float conversion and function calls + v = float(value) + if v < 0.0: + return 0.0 + elif v > 1.0: + return 1.0 + else: + return v def parse_florence2_object_detection_response(