Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed May 15, 2024
1 parent 4f764ad commit 057824b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion vision_agent/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
CLIP,
OCR,
TOOLS,
BboxStats,
BboxIoU,
BboxStats,
BoxDistance,
Crop,
DINOv,
Expand Down
8 changes: 4 additions & 4 deletions vision_agent/tools/tools_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tempfile
from importlib import resources
from pathlib import Path
from typing import Any, Callable, Dict, List, Tuple, Union
from typing import Any, Callable, Dict, List, Tuple, Union, cast

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -255,7 +255,7 @@ def closest_mask_distance(mask1: np.ndarray, mask2: np.ndarray) -> float:
mask1_points = np.transpose(np.nonzero(mask1))
mask2_points = np.transpose(np.nonzero(mask2))
dist_matrix = distance.cdist(mask1_points, mask2_points, "euclidean")
return np.min(dist_matrix)
return cast(float, np.min(dist_matrix))


def closest_box_distance(box1: List[float], box2: List[float]) -> float:
Expand All @@ -276,10 +276,10 @@ def closest_box_distance(box1: List[float], box2: List[float]) -> float:

x11, y11, x12, y12 = box1
x21, y21, x22, y22 = box2

horizontal_distance = np.max([0, x21 - x12, x11 - x22])
vertical_distance = np.max([0, y21 - y12, y11 - y22])
return np.sqrt(horizontal_distance ** 2 + vertical_distance ** 2)
return cast(float, np.sqrt(horizontal_distance**2 + vertical_distance**2))


# Utility and visualization functions
Expand Down

0 comments on commit 057824b

Please sign in to comment.