refactor: 🛠️ update type hints to use built-in types in VLM and validation functions
This commit is contained in:
4 files changed
+17
-8
No files matched your search
@@ -53,3 +53,11 @@ repos:
|
||||
- id: codespell
|
||||
additional_dependencies:
|
||||
- tomli
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.20.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py39-plus"]
|
||||
additional_dependencies:
|
||||
- tomli
|
||||
@@ -118,7 +118,7 @@ def from_paligemma(
|
||||
|
||||
Args:
|
||||
result: String containing paligemma-formatted locations and labels.
|
||||
resolution_wh: Tuple (width, height) to which we scale the box coordinates.
|
||||
resolution_wh: tuple (width, height) to which we scale the box coordinates.
|
||||
classes: Optional list of valid class names. If provided, boxes and labels not
|
||||
in this list are filtered out.
|
||||
|
||||
@@ -423,9 +423,9 @@ def from_google_gemini_2_0(
|
||||
|
||||
def from_google_gemini_2_5(
|
||||
result: str,
|
||||
resolution_wh: Tuple[int, int],
|
||||
classes: Optional[List[str]] = None,
|
||||
) -> Tuple[
|
||||
resolution_wh: tuple[int, int],
|
||||
classes: Optional[list[str]] = None,
|
||||
) -> tuple[
|
||||
np.ndarray,
|
||||
Optional[np.ndarray],
|
||||
np.ndarray,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -139,7 +140,7 @@ def validate_keypoints_fields(
|
||||
validate_data(data, n)
|
||||
|
||||
|
||||
def validate_resolution(resolution: Any) -> Tuple[int, int]:
|
||||
def validate_resolution(resolution: Any) -> tuple[int, int]:
|
||||
if not (isinstance(resolution, tuple) and len(resolution) == 2):
|
||||
raise ValueError(
|
||||
f"""
|
||||
|
||||
@@ -1080,10 +1080,10 @@ def test_florence_2(
|
||||
def test_from_google_gemini_2_5(
|
||||
exception,
|
||||
result: str,
|
||||
resolution_wh: Tuple[int, int],
|
||||
classes: Optional[List[str]],
|
||||
resolution_wh: tuple[int, int],
|
||||
classes: Optional[list[str]],
|
||||
expected_results: Optional[
|
||||
Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]
|
||||
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]
|
||||
],
|
||||
):
|
||||
with exception:
|
||||
|
||||
Reference in new issue
Block a user