Skip to content

Commit 04c07c2

Browse files
committed
Updated BED calls
1 parent 469514d commit 04c07c2

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plotly~=5.14
77
email-validator~=2.0
88
pandas~=1.3
99
ffmpeg-python~=0.2
10-
pillow~=9.5
10+
pillow>=9.5,~=10.0
1111
tqdm~=4.66.1
1212
requests~=2.31.0
1313
aiofiles==23.1.0

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ def delete_annotations(
20952095
20962096
:param project: project name or folder path (e.g., "project1/folder1")
20972097
:type project: str
2098-
:param item_names: item names. If None, all the items in the specified directory will be deleted.
2098+
:param item_names: item names. If None, all the annotations in the specified directory will be deleted.
20992099
:type item_names: list of strs
21002100
"""
21012101

@@ -2538,6 +2538,15 @@ def attach_items(
25382538
25392539
:return: uploaded, failed and duplicated item names
25402540
:rtype: tuple of list of strs
2541+
2542+
Example:
2543+
::
2544+
client = SAClient()
2545+
client.attach_items(
2546+
project = "Medical Annotations",
2547+
attachments = [{"name": "item", "url": "https://..."}]
2548+
)
2549+
25412550
"""
25422551

25432552
project_name, folder_name = extract_project_folder(project)

src/superannotate/lib/core/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def generate_thumb(self):
8282

8383
thumbnail_size = (128, 96)
8484
background = Image.new("RGB", thumbnail_size, "black")
85-
image.thumbnail(thumbnail_size, Image.ANTIALIAS)
85+
image.thumbnail(thumbnail_size, Image.LANCZOS)
8686
(w, h) = image.size
8787
background.paste(
8888
image, ((thumbnail_size[0] - w) // 2, (thumbnail_size[1] - h) // 2)
@@ -99,7 +99,7 @@ def generate_huge(self, base_width: int = 600) -> Tuple[io.BytesIO, float, float
9999
width, height = im.size
100100
buffer = io.BytesIO()
101101
h_size = int(height * base_width / width)
102-
im.resize((base_width, h_size), Image.ANTIALIAS).convert("RGB").save(
102+
im.resize((base_width, h_size), Image.LANCZOS).convert("RGB").save(
103103
buffer, "JPEG"
104104
)
105105
buffer.seek(0)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ async def upload(_chunk: List[ItemToUpload]):
231231
await upload(chunk)
232232
chunk = []
233233
_size = 0
234+
if not chunk:
235+
queue.put_nowait(None)
234236
chunk.append(item_data)
235237
_size += item_data.file_size
236238
if chunk:

src/superannotate/lib/infrastructure/services/annotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def _sync_large_annotation(self, team_id, project_id, item_id):
9090
synced = await session.get(sync_status_url, params=sync_params)
9191
synced = await synced.json()
9292
synced = synced["status"]
93-
await asyncio.sleep(1)
93+
await asyncio.sleep(5)
9494
return synced
9595

9696
async def get_big_annotation(

tests/integration/annotations/test_large_annotations.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class TestAnnotationUploadVector(BaseTestCase):
1818
TEST_FOLDER_PATH = "data_set/sample_vector_annotations_with_tag_classes"
1919
TEST_4_FOLDER_PATH = "data_set/sample_project_vector"
2020
TEST_BIG_FOLDER_PATH = "sample_big_json_vector"
21+
TEST_BIG_ANNOTATION_NAME = "aearth_mov_001.jpg"
22+
TEST_BIG_ANNOTATION_PATH = os.path.join(DATA_SET_PATH, f"sample_big_json_vector/{TEST_BIG_ANNOTATION_NAME}.json")
2123

2224
IMAGE_NAME = "example_image_1.jpg"
2325

@@ -37,6 +39,26 @@ def _get_annotations_from_folder(path):
3739
annotations.append(json.load(open(i)))
3840
return annotations
3941

42+
def test_large_annotation_upload(self):
43+
sa.attach_items(
44+
self.PROJECT_NAME,
45+
[{"name": self.TEST_BIG_ANNOTATION_NAME, "url": f"url_"}]
46+
)
47+
sa.create_annotation_classes_from_classes_json(
48+
self.PROJECT_NAME,
49+
f"{self.big_annotations_folder_path}/classes/classes.json",
50+
)
51+
annotation = json.load(open(self.TEST_BIG_ANNOTATION_PATH))
52+
with self.assertLogs("sa", level="INFO") as cm:
53+
uploaded, _, _ = sa.upload_annotations(
54+
self.PROJECT_NAME, [annotation]
55+
).values()
56+
assert (
57+
"INFO:sa:Uploading 1/1 annotations to the project Test-upload_annotations."
58+
== cm.output[0]
59+
)
60+
assert len(uploaded) == 1
61+
4062
def test_large_annotations_upload_get_download(self):
4163
items_to_attach = [
4264
{"name": f"aearth_mov_00{i}.jpg", "url": f"url_{i}"} for i in range(1, 6)

0 commit comments

Comments
 (0)