Skip to content

Commit 8f4313d

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Fixed Pixel export annotation
1 parent 1129b7c commit 8f4313d

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

src/superannotate/lib/core/usecases.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def __init__(
806806
):
807807
super().__init__(),
808808
self._project = project
809-
self._folder_names = folder_names
809+
self._folder_names = list(folder_names)
810810
self._backend_service = backend_service_provider
811811
self._annotation_statuses = annotation_statuses
812812
self._include_fuse = include_fuse
@@ -856,12 +856,12 @@ def execute(self):
856856
if "error" in response:
857857
raise AppException(response["error"])
858858

859-
report_message = self._project.name
859+
report_message = ""
860860
if self._folder_names:
861-
report_message = f"[{', '.join(self._folder_names)}]"
861+
report_message = f"[{', '.join(self._folder_names)}] "
862862
logger.info(
863-
f"Prepared export {response['name']} for project "
864-
f"{report_message} (project ID {self._project.uuid})."
863+
f"Prepared export {response['name']} for project {self._project.name} "
864+
f"{report_message}(project ID {self._project.uuid})."
865865
)
866866
self._response.data = response
867867

@@ -3437,19 +3437,19 @@ def execute(self):
34373437
)
34383438
if self._project.project_type == constances.ProjectType.PIXEL.value:
34393439
mask_path = None
3440-
if os.path.exists(self._annotation_path) and not self._mask:
3441-
mask_path = self._annotation_path
3440+
png_path = self._annotation_path.replace("___pixel.json", "___save.png")
3441+
if os.path.exists(png_path) and not self._mask:
3442+
mask_path = png_path
34423443
elif self._mask:
34433444
mask_path = self._mask
34443445

34453446
if mask_path:
34463447
with open(mask_path, "rb") as descriptor:
3447-
file = io.BytesIO(descriptor.read())
34483448
bucket.put_object(
34493449
Key=response.data.images[image_data["id"]][
34503450
"annotation_bluemap_path"
34513451
],
3452-
Body=file,
3452+
Body=descriptor.read(),
34533453
)
34543454
if self._verbose:
34553455
logger.info(

tests/integration/test_interface.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,37 @@ def test_upload_images_to_project_image_quality_in_editor(self):
146146
[self.EXAMPLE_IMAGE_1],
147147
image_quality_in_editor='random_string'
148148
)
149+
150+
151+
class TestPixelInterface(BaseTestCase):
152+
PROJECT_NAME = "Interface test"
153+
TEST_FOLDER_PATH = "sample_project_pixel"
154+
PROJECT_DESCRIPTION = "desc"
155+
PROJECT_TYPE = "Pixel"
156+
TEST_FOLDER_NAME = "folder"
157+
EXAMPLE_IMAGE_1 = "example_image_1.jpg"
158+
159+
@property
160+
def data_set_path(self):
161+
return os.path.join(dirname(dirname(__file__)), "data_set")
162+
163+
@property
164+
def folder_path(self):
165+
return os.path.join(self.data_set_path, self.TEST_FOLDER_PATH)
166+
167+
def test_export_annotation(self):
168+
sa.upload_image_to_project(self.PROJECT_NAME, f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}")
169+
sa.create_annotation_classes_from_classes_json(self.PROJECT_NAME, f"{self.folder_path}/classes/classes.json")
170+
sa.upload_image_annotations(
171+
self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}___pixel.json"
172+
)
173+
with tempfile.TemporaryDirectory() as export_dir:
174+
result = sa.prepare_export(
175+
self.PROJECT_NAME,
176+
)
177+
sa.download_export(self.PROJECT_NAME, result, export_dir, True)
178+
with tempfile.TemporaryDirectory() as convert_path:
179+
sa.export_annotation(
180+
export_dir, convert_path, "COCO", "data_set_name", "Pixel", "panoptic_segmentation"
181+
)
182+
pass

0 commit comments

Comments
 (0)