File tree Expand file tree Collapse file tree 4 files changed +17
-26
lines changed Expand file tree Collapse file tree 4 files changed +17
-26
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class MetricResult:
21
21
"""
22
22
23
23
value : float
24
- weight : float = 1
24
+ weight : float = 1.0
25
25
26
26
@staticmethod
27
27
def aggregate (results : Iterable ["MetricResult" ]) -> "MetricResult" :
Original file line number Diff line number Diff line change @@ -24,19 +24,8 @@ def confidence_filter(
24
24
lambda prediction : not hasattr (prediction , "confidence" )
25
25
or prediction .confidence >= min_confidence
26
26
)
27
- predictions_copy .box_predictions = list (
28
- filter (filter_fn , predictions .box_predictions )
29
- )
30
- predictions_copy .polygon_predictions = list (
31
- filter (filter_fn , predictions .polygon_predictions )
32
- )
33
- predictions_copy .cuboid_predictions = list (
34
- filter (filter_fn , predictions .cuboid_predictions )
35
- )
36
- predictions_copy .category_predictions = list (
37
- filter (filter_fn , predictions .category_predictions )
38
- )
39
- predictions_copy .segmentation_predictions = list (
40
- filter (filter_fn , predictions .segmentation_predictions )
41
- )
27
+ for attr in predictions .__dict__ :
28
+ predictions_copy .__dict__ [attr ] = list (
29
+ filter (filter_fn , predictions .__dict__ [attr ])
30
+ )
42
31
return predictions_copy
Original file line number Diff line number Diff line change 1
1
import sys
2
2
from abc import abstractmethod
3
- from typing import List
3
+ from typing import List , Union
4
4
5
- from nucleus .annotation import AnnotationList
6
- from nucleus .prediction import PredictionList
5
+ from nucleus .annotation import AnnotationList , BoxAnnotation , PolygonAnnotation
6
+ from nucleus .prediction import BoxPrediction , PolygonPrediction , PredictionList
7
7
8
8
from .base import Metric , MetricResult
9
9
from .filters import confidence_filter
@@ -90,10 +90,10 @@ def __call__(
90
90
predictions = confidence_filter (
91
91
predictions , self .confidence_threshold
92
92
)
93
- polygon_annotations : List [BoxOrPolygonAnnotation ] = []
93
+ polygon_annotations : List [Union [ BoxAnnotation , PolygonAnnotation ] ] = []
94
94
polygon_annotations .extend (annotations .box_annotations )
95
95
polygon_annotations .extend (annotations .polygon_annotations )
96
- polygon_predictions : List [BoxOrPolygonAnnotation ] = []
96
+ polygon_predictions : List [Union [ BoxPrediction , PolygonPrediction ] ] = []
97
97
polygon_predictions .extend (predictions .box_predictions )
98
98
polygon_predictions .extend (predictions .polygon_predictions )
99
99
Original file line number Diff line number Diff line change 1
1
import sys
2
2
from functools import wraps
3
- from typing import Dict , List , Tuple , Union
3
+ from typing import Dict , List , Tuple , TypeVar
4
4
5
5
import numpy as np
6
6
from scipy .optimize import linear_sum_assignment
12
12
from .base import MetricResult
13
13
from .errors import PolygonAnnotationTypeError
14
14
15
- BoxOrPolygonPrediction = Union [BoxPrediction , PolygonPrediction ]
16
- BoxOrPolygonAnnotation = Union [
17
- BoxAnnotation , PolygonAnnotation , BoxOrPolygonPrediction
18
- ]
15
+ BoxOrPolygonPrediction = TypeVar (
16
+ "BoxOrPolygonPrediction" , BoxPrediction , PolygonPrediction
17
+ )
18
+ BoxOrPolygonAnnotation = TypeVar (
19
+ "BoxOrPolygonAnnotation" , BoxAnnotation , PolygonAnnotation
20
+ )
19
21
20
22
21
23
def polygon_annotation_to_shape (
You can’t perform that action at this time.
0 commit comments