From 8e845caeeb804b21776f31ebbc4cba9aa3108f1b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:44:09 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/core.py | 3 +-- supervision/detection/vlm.py | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 06a2f466..ca821592 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -36,12 +36,12 @@ from supervision.detection.utils import ( from supervision.detection.vlm import ( LMM, VLM, + from_deepseek_vl_2, from_florence_2, from_google_gemini, from_paligemma, from_qwen_2_5_vl, validate_vlm_parameters, - from_deepseek_vl_2, ) from supervision.geometry.core import Position from supervision.utils.internal import deprecated, get_instance_variables @@ -902,7 +902,6 @@ class Detections: LMM.DEEPSEEK_VL_2: VLM.DEEPSEEK_VL_2, LMM.GOOGLE_GEMINI_2_0: VLM.GOOGLE_GEMINI_2_0, LMM.GOOGLE_GEMINI_2_5: VLM.GOOGLE_GEMINI_2_5, - } # (this works even if the LMM enum is wrapped by @deprecated) diff --git a/supervision/detection/vlm.py b/supervision/detection/vlm.py index f8b45d48..35c0c68e 100644 --- a/supervision/detection/vlm.py +++ b/supervision/detection/vlm.py @@ -1,6 +1,6 @@ +import ast import json import re -import ast from enum import Enum from typing import Any, Dict, List, Optional, Tuple, Union @@ -244,9 +244,7 @@ def from_qwen_2_5_vl( def from_deepseek_vl_2( - result: str, - resolution_wh: Tuple[int, int], - classes: Optional[List[str]] = None + result: str, resolution_wh: Tuple[int, int], classes: Optional[List[str]] = None ) -> Tuple[np.ndarray, Optional[np.ndarray], np.ndarray]: """ Parse bounding boxes from deepseek-vl2-formatted text, scale them to the specified @@ -280,8 +278,8 @@ def from_deepseek_vl_2( f"Both dimensions in resolution_wh must be positive. Got ({w}, {h})." ) - label_segments = re.findall(r'<\|ref\|>(.*?)<\|/ref\|>', result, flags=re.DOTALL) - bbox_segments = re.findall(r'<\|det\|>(.*?)<\|/det\|>', result, flags=re.DOTALL) + label_segments = re.findall(r"<\|ref\|>(.*?)<\|/ref\|>", result, flags=re.DOTALL) + bbox_segments = re.findall(r"<\|det\|>(.*?)<\|/det\|>", result, flags=re.DOTALL) if len(label_segments) != len(bbox_segments): return np.empty((0, 4)), None, np.empty((0,), dtype=str) @@ -290,7 +288,7 @@ def from_deepseek_vl_2( for label_str, bbox_str in zip(label_segments, bbox_segments): label_str = label_str.strip() - raw_box_groups = re.findall(r'\[\[.*?\]\]', bbox_str, flags=re.DOTALL) + raw_box_groups = re.findall(r"\[\[.*?\]\]", bbox_str, flags=re.DOTALL) if not raw_box_groups: continue