Skip to content

Commit 42d8e68

Browse files
committed
Added ability to upload annotations for Multimodal projects.
1 parent fd15298 commit 42d8e68

File tree

9 files changed

+480
-33
lines changed

9 files changed

+480
-33
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,31 @@ def upload_annotations(
19651965
"skipped": []
19661966
}
19671967
1968+
Example Usage with JSONL Upload:
1969+
::
1970+
import json
1971+
from pathlib import Path
1972+
from superannotate import SAClient
1973+
1974+
# Assuming annotations are stored in JSONL format
1975+
annotations_path = Path("annotations.jsonl")
1976+
annotations = []
1977+
1978+
# Reading the JSONL file and converting it into a list of dictionaries
1979+
with annotations_path.open("r", encoding="utf-8") as f:
1980+
for line in f:
1981+
annotations.append(json.loads(line))
1982+
1983+
# Initialize the Superannotate client
1984+
sa = SAClient()
1985+
1986+
# Call the upload_annotations function
1987+
response = client.upload_annotations(
1988+
project="project1/folder1",
1989+
annotations=annotations,
1990+
keep_status=True
1991+
)
1992+
19681993
"""
19691994
if keep_status is not None:
19701995
warnings.warn(

src/superannotate/lib/core/entities/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from lib.core.entities.items import TiledEntity
1313
from lib.core.entities.items import VideoEntity
1414
from lib.core.entities.project import AttachmentEntity
15+
from lib.core.entities.project import CategoryEntity
1516
from lib.core.entities.project import ContributorEntity
1617
from lib.core.entities.project import ProjectEntity
1718
from lib.core.entities.project import SettingEntity
@@ -41,6 +42,7 @@
4142
# project
4243
"ProjectEntity",
4344
"WorkflowEntity",
45+
"CategoryEntity",
4446
"ContributorEntity",
4547
"ConfigEntity",
4648
"StepEntity",

src/superannotate/lib/core/entities/project.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,8 @@ def is_system(self):
179179

180180
class Config:
181181
extra = Extra.ignore
182+
183+
184+
class CategoryEntity(BaseModel):
185+
id: Optional[int]
186+
name: Optional[str]

src/superannotate/lib/core/serviceproviders.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from lib.core import entities
1111
from lib.core.conditions import Condition
12+
from lib.core.entities import CategoryEntity
1213
from lib.core.jsx_conditions import Query
1314
from lib.core.reporter import Reporter
1415
from lib.core.service_types import AnnotationClassListResponse
@@ -87,6 +88,16 @@ def list_workflow_statuses(self, project_id: int, workflow_id: int):
8788
def list_workflow_roles(self, project_id: int, workflow_id: int):
8889
raise NotImplementedError
8990

91+
@abstractmethod
92+
def list_project_categories(self, project_id: int) -> List[entities.CategoryEntity]:
93+
raise NotImplementedError
94+
95+
@abstractmethod
96+
def create_project_categories(
97+
self, project_id: int, categories: List[CategoryEntity]
98+
):
99+
raise NotImplementedError
100+
90101

91102
class BaseProjectService(SuperannotateServiceProvider):
92103
@abstractmethod

0 commit comments

Comments
 (0)