Skip to content

Commit 6b36523

Browse files
committed
merge
2 parents 42c3795 + bb215e2 commit 6b36523

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ def move_images(
712712
source_project: Union[NotEmptyStr, dict],
713713
image_names: Optional[List[NotEmptyStr]],
714714
destination_project: Union[NotEmptyStr, dict],
715-
*_,
716-
**__,
715+
*args,
716+
**kwargs,
717717
):
718718
"""Move images in bulk between folders in a project
719719
@@ -994,7 +994,9 @@ def delete_image(project: Union[NotEmptyStr, dict], image_name: str):
994994

995995
@Trackable
996996
@validate_arguments
997-
def get_image_metadata(project: Union[NotEmptyStr, dict], image_name: str, *_, **__):
997+
def get_image_metadata(
998+
project: Union[NotEmptyStr, dict], image_name: str, *args, **kwargs
999+
):
9981000
"""Returns image metadata
9991001
10001002
:param project: project name or folder path (e.g., "project1/folder1")
@@ -2258,8 +2260,8 @@ def attach_image_urls_to_project(
22582260
with tqdm(
22592261
total=use_case.attachments_count, desc="Attaching urls"
22602262
) as progress_bar:
2261-
for _ in use_case.execute():
2262-
progress_bar.update(1)
2263+
for attached in use_case.execute():
2264+
progress_bar.update(attached)
22632265
uploaded, duplications = use_case.data
22642266
uploaded = [i["name"] for i in uploaded]
22652267
duplications.extend(duplicate_images)
@@ -2311,8 +2313,8 @@ def attach_video_urls_to_project(
23112313
with tqdm(
23122314
total=use_case.attachments_count, desc="Attaching urls"
23132315
) as progress_bar:
2314-
for _ in use_case.execute():
2315-
progress_bar.update(1)
2316+
for attached in use_case.execute():
2317+
progress_bar.update(attached)
23162318
uploaded, duplications = use_case.data
23172319
uploaded = [i["name"] for i in uploaded]
23182320
duplications.extend(duplicate_images)
@@ -3522,8 +3524,8 @@ def attach_document_urls_to_project(
35223524
with tqdm(
35233525
total=use_case.attachments_count, desc="Attaching urls"
35243526
) as progress_bar:
3525-
for _ in use_case.execute():
3526-
progress_bar.update(1)
3527+
for attached in use_case.execute():
3528+
progress_bar.update(attached)
35273529
uploaded, duplications = use_case.data
35283530
uploaded = [i["name"] for i in uploaded]
35293531
duplications.extend(duplicate_images)

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,8 @@ def execute(self):
829829

830830
outline_color = 4 * (255,)
831831
for instance in self.annotations["instances"]:
832+
if (not instance.get("className")) or (not class_color_map.get(instance["className"])):
833+
continue
832834
color = class_color_map.get(instance["className"])
833835
if not color:
834836
class_color_map[instance["className"]] = self.generate_color()
@@ -904,9 +906,7 @@ def execute(self):
904906
weight, height = image.get_size()
905907
empty_image_arr = np.full((height, weight, 4), [0, 0, 0, 255], np.uint8)
906908
for annotation in self.annotations["instances"]:
907-
if annotation.get("className") and not class_color_map.get(
908-
annotation["className"]
909-
):
909+
if (not annotation.get("className")) or (not class_color_map.get(annotation["className"])):
910910
continue
911911
fill_color = *class_color_map[annotation["className"]], 255
912912
for part in annotation["parts"]:
@@ -1866,6 +1866,10 @@ def __init__(
18661866
def attachments_count(self):
18671867
return len(self._attachments)
18681868

1869+
@property
1870+
def chunks_count(self):
1871+
return int(self.attachments_count / self.CHUNK_SIZE)
1872+
18691873
def validate_limitations(self):
18701874
attachments_count = self.attachments_count
18711875
response = self._backend_service.get_limitations(
@@ -1915,7 +1919,7 @@ def execute(self):
19151919
uploaded, duplicated = response.data
19161920
uploaded_files.extend(uploaded)
19171921
duplicated_files.extend(duplicated)
1918-
yield
1922+
yield len(uploaded) + len(duplicated)
19191923
self._response.data = uploaded_files, duplicated_files
19201924
return self._response
19211925

src/superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "5.0.0b31"
1+
__version__ = "5.0.0b32"

tests/integration/test_fuse_gen.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,27 @@ def test_fuse_image_create_pixel(self):
192192
self.assertEqual(im1_array.shape, im2_array.shape)
193193
self.assertEqual(im1_array.dtype, im2_array.dtype)
194194
self.assertTrue(np.array_equal(im1_array, im2_array))
195+
196+
def test_fuse_image_create_pixel_with_no_classes(self):
197+
with tempfile.TemporaryDirectory() as temp_dir:
198+
temp_dir = pathlib.Path(temp_dir)
199+
200+
sa.upload_image_to_project(
201+
self.PIXEL_PROJECT_NAME,
202+
f"{self.pixel_folder_path}/{self.EXAMPLE_IMAGE_1}",
203+
annotation_status="QualityCheck",
204+
)
205+
sa.upload_image_annotations(
206+
project=self.PIXEL_PROJECT_NAME,
207+
image_name=self.EXAMPLE_IMAGE_1,
208+
annotation_json=f"{self.pixel_folder_path}/{self.EXAMPLE_IMAGE_1}___pixel.json",
209+
mask=f"{self.pixel_folder_path}/{self.EXAMPLE_IMAGE_1}___save.png",
210+
)
211+
212+
sa.download_image(
213+
self.PIXEL_PROJECT_NAME,
214+
self.EXAMPLE_IMAGE_1,
215+
temp_dir,
216+
include_annotations=True,
217+
include_fuse=True,
218+
)

0 commit comments

Comments
 (0)