Skip to content

Commit 8bea11e

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Changed fuse image transparency
1 parent 16fd3c5 commit 8bea11e

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

src/superannotate/lib/core/usecases.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,7 @@ def execute(self):
32303230
if self._include_annotations:
32313231
annotations = self.download_annotation_use_case.execute().data
32323232

3233-
if self._include_annotations and self._include_fuse:
3233+
if self._include_annotations and (self._include_fuse or self._include_overlay):
32343234
classes = self.get_annotation_classes_ues_case.execute().data
32353235
fuse_image = (
32363236
CreateFuseImageUseCase(
@@ -3279,9 +3279,6 @@ def __init__(
32793279
self._mask = mask
32803280
self._verbose = verbose
32813281
self._annotation_path = annotation_path
3282-
self.unknown_classes = []
3283-
self.unknown_attribute_groups = []
3284-
self.unknown_attributes = []
32853282

32863283
def validate_project_type(self):
32873284
if self._project.project_type in constances.LIMITED_FUNCTIONS:
@@ -3384,7 +3381,6 @@ def fill_classes_data(self, annotations: dict):
33843381
annotation_class_name = annotation["className"]
33853382
if annotation_class_name not in annotation_classes.keys():
33863383
if annotation_class_name not in unknown_classes:
3387-
self.unknown_classes.append(annotation_class_name)
33883384
unknown_classes[annotation_class_name] = {
33893385
"id": -(len(unknown_classes) + 1),
33903386
"attribute_groups": {},
@@ -3402,14 +3398,15 @@ def fill_classes_data(self, annotations: dict):
34023398
for annotation in [i for i in annotations["instances"] if "className" in i]:
34033399
annotation_class_name = annotation["className"]
34043400
if annotation_class_name not in annotation_classes.keys():
3401+
logger.warning(f"Couldn't find annotation class {annotation_class_name}")
34053402
continue
34063403
annotation["classId"] = annotation_classes[annotation_class_name]["id"]
34073404
for attribute in annotation["attributes"]:
34083405
if (
34093406
attribute["groupName"]
34103407
not in annotation_classes[annotation_class_name]["attribute_groups"]
34113408
):
3412-
self.unknown_attribute_groups.append(attribute["groupName"])
3409+
logger.warning(f"Couldn't find annotation group {attribute['groupName']}.")
34133410
continue
34143411
attribute["groupId"] = annotation_classes[annotation_class_name][
34153412
"attribute_groups"
@@ -3421,22 +3418,15 @@ def fill_classes_data(self, annotations: dict):
34213418
][attribute["groupName"]]["attributes"]
34223419
):
34233420
del attribute["groupId"]
3424-
self.unknown_attributes.append(attribute["name"])
3421+
logger.warning(
3422+
f"Couldn't find annotation name {attribute['name']} in"
3423+
f" annotation group {attribute['groupName']}",
3424+
)
34253425
continue
34263426
attribute["id"] = annotation_classes[annotation_class_name][
34273427
"attribute_groups"
34283428
][attribute["groupName"]]["attributes"][attribute["name"]]
34293429

3430-
def report_unknown_data(self):
3431-
if self.unknown_classes:
3432-
logger.warning(f"Unknown classes [{', '.join(self.unknown_classes)}]")
3433-
if self.unknown_attribute_groups:
3434-
logger.warning(
3435-
f"Unknown attribute_groups [{', '.join(self.unknown_attribute_groups)}]"
3436-
)
3437-
if self.unknown_attributes:
3438-
logger.warning(f"Unknown attributes [{', '.join(self.unknown_attributes)}]")
3439-
34403430
def execute(self):
34413431
if self.is_valid():
34423432
image_data = self._backend_service.get_bulk_images(
@@ -3464,8 +3454,6 @@ def execute(self):
34643454
resource = session.resource("s3")
34653455
bucket = resource.Bucket(response.data.bucket)
34663456
self.fill_classes_data(self._annotations)
3467-
# skipped report
3468-
# self.report_unknown_data()
34693457
bucket.put_object(
34703458
Key=response.data.images[image_data["id"]]["annotation_json_path"],
34713459
Body=json.dumps(self._annotations),

tests/integration/test_get_exports.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,27 @@ def test_get_exports(self):
3939
exports_new = sa.get_exports(self.PROJECT_NAME)
4040

4141
assert len(exports_new) == len(exports_old) + 1
42+
43+
44+
class TestPixelExportConvert(BaseTestCase):
45+
PROJECT_NAME = "Pixel_Export"
46+
PROJECT_DESCRIPTION = "Desc"
47+
PROJECT_TYPE = "Pixel"
48+
TEST_FOLDER_PTH = "data_set"
49+
TEST_FOLDER_PATH = "data_set/sample_project_pixel"
50+
51+
@property
52+
def folder_path(self):
53+
return os.path.join(dirname(dirname(__file__)), self.TEST_FOLDER_PATH)
54+
55+
def test_convert_pixel_exported_data(self):
56+
sa.upload_images_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
57+
sa.upload_annotations_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
58+
export = sa.prepare_export(self.PROJECT_NAME)
59+
with tempfile.TemporaryDirectory() as tmp_dir:
60+
sa.download_export(self.PROJECT_NAME, export["name"], tmp_dir)
61+
with tempfile.TemporaryDirectory() as converted_data_tmp_dir:
62+
sa.export_annotation(
63+
tmp_dir, converted_data_tmp_dir, "COCO", "export", "Pixel", "panoptic_segmentation"
64+
)
65+
self.assertEqual(1, len(list(glob.glob(converted_data_tmp_dir + "/*.json"))))

0 commit comments

Comments
 (0)