Skip to content

Commit c3b1627

Browse files
committed
Add annotation type validation
1 parent a5f47a0 commit c3b1627

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from lib.app.interface.types import ClassesJson
3535
from lib.app.interface.types import NotEmptyStr
3636
from lib.app.interface.types import Status
37+
from lib.app.interface.types import AnnotationType
3738
from lib.app.interface.types import validate_arguments
3839
from lib.app.mixp.decorators import Trackable
3940
from lib.app.serializers import BaseSerializers
@@ -2742,7 +2743,7 @@ def benchmark(
27422743
folder_names: List[str],
27432744
export_root: Optional[Union[str, Path]] = None,
27442745
image_list=None,
2745-
annot_type="bbox",
2746+
annot_type=Optional[AnnotationType],
27462747
show_plots=False,
27472748
):
27482749
"""Computes benchmark score for each instance of given images that are present both gt_project_name project and projects in folder_names list:
@@ -2804,7 +2805,7 @@ def consensus(
28042805
folder_names: NotEmptyStr,
28052806
export_root: Optional[Union[NotEmptyStr, Path]] = None,
28062807
image_list: Optional[List[NotEmptyStr]] = None,
2807-
annot_type: Optional[NotEmptyStr] = "bbox",
2808+
annot_type: Optional[AnnotationType] = "bbox",
28082809
show_plots: Optional[StrictBool] = False,
28092810
):
28102811
"""Computes consensus score for each instance of given images that are present in at least 2 of the given projects:
@@ -3322,7 +3323,7 @@ def upload_image_to_project(
33223323
project: NotEmptyStr,
33233324
img,
33243325
image_name: Optional[NotEmptyStr] = None,
3325-
annotation_status: Optional[NotEmptyStr] = "NotStarted",
3326+
annotation_status: Optional[Status] = "NotStarted",
33263327
from_s3_bucket=None,
33273328
image_quality_in_editor: Optional[NotEmptyStr] = None,
33283329
):
@@ -3412,7 +3413,7 @@ def search_models(
34123413
def upload_images_to_project(
34133414
project: NotEmptyStr,
34143415
img_paths: List[NotEmptyStr],
3415-
annotation_status: Optional[NotEmptyStr] = "NotStarted",
3416+
annotation_status: Optional[Status] = "NotStarted",
34163417
from_s3_bucket=None,
34173418
image_quality_in_editor: Optional[NotEmptyStr] = None,
34183419
):

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

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

26+
class AnnotationType(StrictStr):
27+
@classmethod
28+
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+
return value
2633

2734
class AttributeGroup(BaseModel):
2835
name: StrictStr

0 commit comments

Comments
 (0)