Skip to content

Commit d5ac83a

Browse files
committed
Fix annotation type
1 parent c3b1627 commit d5ac83a

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
from lib.app.helpers import extract_project_folder
3232
from lib.app.helpers import get_annotation_paths
3333
from lib.app.helpers import reformat_metrics_json
34+
from lib.app.interface.types import AnnotationType
3435
from lib.app.interface.types import ClassesJson
3536
from lib.app.interface.types import NotEmptyStr
3637
from lib.app.interface.types import Status
37-
from lib.app.interface.types import AnnotationType
3838
from lib.app.interface.types import validate_arguments
3939
from lib.app.mixp.decorators import Trackable
4040
from lib.app.serializers import BaseSerializers
@@ -2743,7 +2743,7 @@ def benchmark(
27432743
folder_names: List[str],
27442744
export_root: Optional[Union[str, Path]] = None,
27452745
image_list=None,
2746-
annot_type=Optional[AnnotationType],
2746+
annot_type: Optional[AnnotationType] = "bbox",
27472747
show_plots=False,
27482748
):
27492749
"""Computes benchmark score for each instance of given images that are present both gt_project_name project and projects in folder_names list:
@@ -3002,7 +3002,7 @@ def get_plottable_cols(df):
30023002
def add_annotation_bbox_to_image(
30033003
project: NotEmptyStr,
30043004
image_name: NotEmptyStr,
3005-
bbox: List,
3005+
bbox: List[float],
30063006
annotation_class_name: NotEmptyStr,
30073007
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
30083008
error: Optional[StrictBool] = None,
@@ -3037,7 +3037,7 @@ def add_annotation_bbox_to_image(
30373037
def add_annotation_polyline_to_image(
30383038
project: NotEmptyStr,
30393039
image_name: NotEmptyStr,
3040-
polyline: List,
3040+
polyline: List[float],
30413041
annotation_class_name: NotEmptyStr,
30423042
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
30433043
error: Optional[StrictBool] = None,
@@ -3071,9 +3071,9 @@ def add_annotation_polyline_to_image(
30713071
def add_annotation_polygon_to_image(
30723072
project: NotEmptyStr,
30733073
image_name: NotEmptyStr,
3074-
polygon: List,
3074+
polygon: List[float],
30753075
annotation_class_name: NotEmptyStr,
3076-
annotation_class_attributes = None,
3076+
annotation_class_attributes=None,
30773077
error: Optional[StrictBool] = None,
30783078
):
30793079
"""Add a polygon annotation to image annotations
@@ -3106,7 +3106,7 @@ def add_annotation_polygon_to_image(
31063106
def add_annotation_point_to_image(
31073107
project: NotEmptyStr,
31083108
image_name: NotEmptyStr,
3109-
point: List,
3109+
point: List[float],
31103110
annotation_class_name: NotEmptyStr,
31113111
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
31123112
error: Optional[StrictBool] = None,
@@ -3139,7 +3139,7 @@ def add_annotation_point_to_image(
31393139
def add_annotation_ellipse_to_image(
31403140
project: NotEmptyStr,
31413141
image_name: NotEmptyStr,
3142-
ellipse: List,
3142+
ellipse: List[float],
31433143
annotation_class_name: NotEmptyStr,
31443144
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
31453145
error: Optional[StrictBool] = None,
@@ -3173,8 +3173,8 @@ def add_annotation_ellipse_to_image(
31733173
def add_annotation_template_to_image(
31743174
project: NotEmptyStr,
31753175
image_name: NotEmptyStr,
3176-
template_points: List,
3177-
template_connections: List,
3176+
template_points: List[float],
3177+
template_connections: List[int],
31783178
annotation_class_name: NotEmptyStr,
31793179
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
31803180
error: Optional[StrictBool] = None,
@@ -3219,7 +3219,7 @@ def add_annotation_template_to_image(
32193219
def add_annotation_cuboid_to_image(
32203220
project: NotEmptyStr,
32213221
image_name: NotEmptyStr,
3222-
cuboid: List,
3222+
cuboid: List[float],
32233223
annotation_class_name: NotEmptyStr,
32243224
annotation_class_attributes: Optional[List[NotEmptyStr]] = None,
32253225
error: Optional[StrictBool] = None,
@@ -3256,7 +3256,7 @@ def add_annotation_comment_to_image(
32563256
project: NotEmptyStr,
32573257
image_name: NotEmptyStr,
32583258
comment_text: NotEmptyStr,
3259-
comment_coords: List,
3259+
comment_coords: List[float],
32603260
comment_author: NotEmptyStr,
32613261
resolved: Optional[StrictBool] = False,
32623262
):
@@ -3541,7 +3541,7 @@ def _upload_s3_image(image_path: str):
35413541
@Trackable
35423542
@validate_arguments
35433543
def aggregate_annotations_as_df(
3544-
project_root: Union[NotEmptyStr,Path],
3544+
project_root: Union[NotEmptyStr, Path],
35453545
include_classes_wo_annotations: Optional[StrictBool] = False,
35463546
include_comments: Optional[StrictBool] = False,
35473547
include_tags: Optional[StrictBool] = False,

src/superannotate/lib/app/interface/types.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@ def validate(cls, value: Union[str]) -> Union[str]:
2323
raise TypeError(f"Available statuses is {', '.join(AnnotationStatus)}. ")
2424
return value
2525

26+
2627
class AnnotationType(StrictStr):
28+
VALID_TYPES = ["bbox", "polygon", "point"]
29+
2730
@classmethod
2831
def validate(cls, value: Union[str]) -> Union[str]:
29-
VALID_TYPES = ["bbox","polygon","points"]
30-
if value.lower() not in VALID_TYPES:
31-
raise TypeError(f"Available annotation_types are {', '.join(VALID_TYPES)}. ")
32+
if value.lower() not in cls.VALID_TYPES:
33+
raise TypeError(
34+
f"Available annotation_types are {', '.join(cls.VALID_TYPES)}. "
35+
)
3236
return value
3337

38+
3439
class AttributeGroup(BaseModel):
3540
name: StrictStr
3641
is_multiselect: Optional[bool]

0 commit comments

Comments
 (0)