Skip to content

Commit 35090b9

Browse files
committed
Fix pixel annotation upload
1 parent 87ca00f commit 35090b9

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,13 @@ def upload_video_to_project(
18171817
"""
18181818

18191819
project_name, folder_name = extract_project_folder(project)
1820+
1821+
project = controller.get_project_metadata(project_name).data
1822+
if project["project"].project_type in [
1823+
constances.ProjectType.VIDEO.value,
1824+
constances.ProjectType.DOCUMENT.value,
1825+
]:
1826+
raise AppException(LIMITED_FUNCTIONS[project["project"].project_type])
18201827
project_folder_name = project_name + (f"/{folder_name}" if folder_name else "")
18211828

18221829
uploaded_paths = []
@@ -2558,6 +2565,16 @@ def upload_image_annotations(
25582565
:param mask: BytesIO object or filepath to mask annotation for pixel projects in SuperAnnotate format
25592566
:type mask: BytesIO or Path-like (str or Path)
25602567
"""
2568+
2569+
project_name, folder_name = extract_project_folder(project)
2570+
2571+
project = controller.get_project_metadata(project_name).data
2572+
if project["project"].project_type in [
2573+
constances.ProjectType.VIDEO.value,
2574+
constances.ProjectType.DOCUMENT.value,
2575+
]:
2576+
raise AppException(LIMITED_FUNCTIONS[project["project"].project_type])
2577+
25612578
if not mask:
25622579
if not isinstance(annotation_json, dict):
25632580
mask_path = str(annotation_json).replace("___pixel.json", "___save.png")
@@ -2573,7 +2590,6 @@ def upload_image_annotations(
25732590
if verbose:
25742591
logger.info("Uploading annotations from %s.", annotation_json)
25752592
annotation_json = json.load(open(annotation_json))
2576-
project_name, folder_name = extract_project_folder(project)
25772593
response = controller.upload_image_annotations(
25782594
project_name=project_name,
25792595
folder_name=folder_name,

src/superannotate/lib/core/usecases/annotations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,16 @@ def execute(self):
406406
Body=json.dumps(annotation_json),
407407
)
408408
if self._project.project_type == constances.ProjectType.PIXEL.value:
409-
if self._mask:
409+
mask_path = self._annotation_path.replace(
410+
"___pixel.json", constances.ANNOTATION_MASK_POSTFIX
411+
)
412+
with open(mask_path, "rb") as mask_file:
413+
file = io.BytesIO(mask_file.read())
410414
bucket.put_object(
411415
Key=self.annotation_upload_data.images[self._image.uuid][
412416
"annotation_bluemap_path"
413417
],
414-
Body=self._mask,
418+
Body=file,
415419
)
416420
if self._verbose:
417421
logger.info(

0 commit comments

Comments
 (0)