|
1 | 1 | import sys |
2 | 2 | from functools import wraps |
3 | | -from typing import Dict, List, Tuple, TypeVar |
| 3 | +from typing import Dict, List, Tuple |
4 | 4 |
|
5 | 5 | import numpy as np |
6 | 6 | from scipy.optimize import linear_sum_assignment |
7 | | -from shapely.geometry import Polygon |
8 | 7 |
|
9 | 8 | from nucleus.annotation import BoxAnnotation, PolygonAnnotation |
10 | | -from nucleus.prediction import BoxPrediction, PolygonPrediction |
| 9 | + |
| 10 | +from .custom_types import BoxOrPolygonAnnotation, BoxOrPolygonPrediction |
| 11 | + |
| 12 | +try: |
| 13 | + from shapely.geometry import Polygon |
| 14 | +except ModuleNotFoundError: |
| 15 | + from .shapely_not_installed import ShapelyNotInstalled |
| 16 | + |
| 17 | + Polygon = ShapelyNotInstalled |
| 18 | + |
11 | 19 |
|
12 | 20 | from .base import ScalarResult |
13 | 21 | from .errors import PolygonAnnotationTypeError |
14 | 22 |
|
15 | | -BoxOrPolygonPrediction = TypeVar( |
16 | | - "BoxOrPolygonPrediction", BoxPrediction, PolygonPrediction |
17 | | -) |
18 | | -BoxOrPolygonAnnotation = TypeVar( |
19 | | - "BoxOrPolygonAnnotation", BoxAnnotation, PolygonAnnotation |
20 | | -) |
21 | | -BoxOrPolygonAnnoOrPred = TypeVar( |
22 | | - "BoxOrPolygonAnnoOrPred", |
23 | | - BoxAnnotation, |
24 | | - PolygonAnnotation, |
25 | | - BoxPrediction, |
26 | | - PolygonPrediction, |
27 | | -) |
28 | | - |
29 | 23 |
|
30 | 24 | def polygon_annotation_to_shape( |
31 | 25 | annotation: BoxOrPolygonAnnotation, |
|
0 commit comments