Skip to content

Commit 078f7ad

Browse files
authored
Merge pull request #733 from superannotateai/FRIDAY_2985
Added ability to upload annotations for Multimodal projects.
2 parents fd15298 + fae81f9 commit 078f7ad

File tree

13 files changed

+575
-33
lines changed

13 files changed

+575
-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/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def setup_logging(level=DEFAULT_LOGGING_LEVEL, file_path=LOG_FILE_LOCATION):
179179
"Tokenization",
180180
"ImageAutoAssignEnable",
181181
"TemplateState",
182+
"CategorizeItems",
182183
]
183184

184185
__alL__ = (

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/service_types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ class ProjectResponse(ServiceResponse):
226226
res_data: entities.ProjectEntity = None
227227

228228

229+
class ListCategoryResponse(ServiceResponse):
230+
res_data: List[entities.CategoryEntity] = None
231+
232+
229233
class WorkflowResponse(ServiceResponse):
230234
res_data: entities.WorkflowEntity = None
231235

src/superannotate/lib/core/serviceproviders.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from lib.core.service_types import FolderListResponse
1616
from lib.core.service_types import FolderResponse
1717
from lib.core.service_types import IntegrationListResponse
18+
from lib.core.service_types import ListCategoryResponse
1819
from lib.core.service_types import ProjectListResponse
1920
from lib.core.service_types import ProjectResponse
2021
from lib.core.service_types import ServiceResponse
@@ -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) -> ListCategoryResponse:
93+
raise NotImplementedError
94+
95+
@abstractmethod
96+
def create_project_categories(
97+
self, project_id: int, categories: List[str]
98+
) -> ServiceResponse:
99+
raise NotImplementedError
100+
90101

91102
class BaseProjectService(SuperannotateServiceProvider):
92103
@abstractmethod
@@ -350,6 +361,12 @@ def delete_multiple(
350361
) -> ServiceResponse:
351362
raise NotImplementedError
352363

364+
@abstractmethod
365+
def bulk_attach_categories(
366+
self, project_id: int, folder_id: int, item_category_map: Dict[int, int]
367+
) -> bool:
368+
raise NotImplementedError
369+
353370

354371
class BaseAnnotationService(SuperannotateServiceProvider):
355372
@abstractmethod

0 commit comments

Comments
 (0)