From efe59cb91c665004247d2d326c0e1895984cd0f4 Mon Sep 17 00:00:00 2001 From: Onuralp SEZER Date: Mon, 14 Jul 2025 20:57:07 +0300 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A7=B9=20use=20same=20var=20name?= =?UTF-8?q?=20compare=20to=20other=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/vlm.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/supervision/detection/vlm.py b/supervision/detection/vlm.py index 664bb6f7..030db73e 100644 --- a/supervision/detection/vlm.py +++ b/supervision/detection/vlm.py @@ -389,14 +389,15 @@ def from_google_gemini_2_0( return np.empty((0, 4)), None, np.empty((0,), dtype=str) labels = [] - xyxy = [] + boxes_list = [] + for item in data: if "box_2d" not in item or "label" not in item: continue labels.append(item["label"]) box = item["box_2d"] # Gemini bbox order is [y_min, x_min, y_max, x_max] - xyxy.append( + boxes_list.append( denormalize_boxes( np.array([box[1], box[0], box[3], box[2]]).astype(np.float64), resolution_wh=(w, h), @@ -404,10 +405,10 @@ def from_google_gemini_2_0( ) ) - if not xyxy: + if not boxes_list: return np.empty((0, 4)), None, np.empty((0,), dtype=str) - xyxy = np.array(xyxy) + xyxy = np.array(boxes_list) class_name = np.array(labels) class_id = None @@ -487,7 +488,7 @@ def from_google_gemini_2_5( None, ) - xyxy_list: list = [] + boxes_list: list = [] labels_list: list = [] confidence_list: Optional[list] = [] masks_list: Optional[list] = [] @@ -503,7 +504,7 @@ def from_google_gemini_2_5( resolution_wh=(w, h), normalization_factor=1000, ) - xyxy_list.append(absolute_bbox) + boxes_list.append(absolute_bbox) if "mask" in item: if masks_list is not None: @@ -540,7 +541,7 @@ def from_google_gemini_2_5( else: confidence_list = None - if not xyxy_list: + if not boxes_list: return ( np.empty((0, 4)), np.array([], dtype=int), @@ -549,7 +550,7 @@ def from_google_gemini_2_5( None, ) - xyxy = np.array(xyxy_list, dtype=float) + xyxy = np.array(boxes_list, dtype=float) class_name = np.array(labels_list) class_id: np.ndarray