Skip to content

Commit 73d3dfc

Browse files
committed
Fix set image statutes
1 parent e3469fd commit 73d3dfc

File tree

5 files changed

+42
-39
lines changed

5 files changed

+42
-39
lines changed

superannotate/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def consensus(*args, **kwargs):
5050
create_fuse_image, delete_image, download_image, download_image_annotations,
5151
download_image_preannotations, get_image_annotations, get_image_bytes,
5252
get_image_metadata, get_image_preannotations, search_images,
53-
set_image_annotation_status, upload_image_annotations
53+
set_image_annotation_status, set_images_annotation_statuses,
54+
upload_image_annotations
5455
)
5556
from .db.project_api import (
5657
create_folder, delete_folders, get_folder_metadata,
57-
get_project_and_folder_metadata, rename_folder, search_folders,
58-
set_images_annotation_statuses
58+
get_project_and_folder_metadata, rename_folder, search_folders
5959
)
6060
from .db.project_images import (
6161
assign_images, copy_image, copy_images, delete_images, move_image,

superannotate/db/images.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,3 +1078,40 @@ def create_fuse_image(
10781078
return (fuse_path, overlay_path)
10791079
else:
10801080
return (fuse_path, )
1081+
1082+
1083+
def set_images_annotation_statuses(project, image_names, annotation_status):
1084+
"""Sets annotation statuses of images
1085+
1086+
:param project: project name or folder path (e.g., "project1/folder1")
1087+
:type project: str
1088+
:param image_names: image names. If None, all the images in the project will be used
1089+
:type image_names: list of str
1090+
:param annotation_status: annotation status to set,
1091+
should be one of NotStarted InProgress QualityCheck Returned Completed Skipped
1092+
:type annotation_status: str
1093+
"""
1094+
NUM_TO_SEND = 500
1095+
project, project_folder = get_project_and_folder_metadata(project)
1096+
params = {"team_id": project["team_id"], "project_id": project["id"]}
1097+
annotation_status = common.annotation_status_str_to_int(annotation_status)
1098+
data = {
1099+
"annotation_status": annotation_status,
1100+
"folder_id": project_folder["id"]
1101+
}
1102+
if image_names is None:
1103+
image_names = search_images(project)
1104+
for start_index in range(0, len(image_names), NUM_TO_SEND):
1105+
data["image_names"] = image_names[start_index:start_index + NUM_TO_SEND]
1106+
response = _api.send_request(
1107+
req_type='PUT',
1108+
path=f'/image/updateAnnotationStatusBulk',
1109+
params=params,
1110+
json_req=data
1111+
)
1112+
if not response.ok:
1113+
raise SABaseException(
1114+
response.status_code,
1115+
"Couldn't change annotation statuses " + response.text
1116+
)
1117+
logger.info("Annotations status of images changed")

superannotate/db/project_api.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -253,38 +253,3 @@ def rename_folder(project, new_folder_name):
253253
"Folder %s renamed to %s in project %s", project_folder["name"],
254254
new_folder_name, project["name"]
255255
)
256-
257-
258-
def set_images_annotation_statuses(project, image_names, annotation_status):
259-
"""Sets annotation statuses of images
260-
261-
:param project: project name or folder path (e.g., "project1/folder1")
262-
:type project: str
263-
:param image_names: image names
264-
:type image_names: list of str
265-
:param annotation_status: annotation status to set,
266-
should be one of NotStarted InProgress QualityCheck Returned Completed Skipped
267-
:type annotation_status: str
268-
"""
269-
NUM_TO_SEND = 500
270-
project, project_folder = get_project_and_folder_metadata(project)
271-
params = {"team_id": project["team_id"], "project_id": project["id"]}
272-
annotation_status = common.annotation_status_str_to_int(annotation_status)
273-
data = {
274-
"annotation_status": annotation_status,
275-
"folder_id": project_folder["id"]
276-
}
277-
for start_index in range(0, len(image_names), NUM_TO_SEND):
278-
data["image_names"] = image_names[start_index:start_index + NUM_TO_SEND]
279-
response = _api.send_request(
280-
req_type='PUT',
281-
path=f'/image/updateAnnotationStatusBulk',
282-
params=params,
283-
json_req=data
284-
)
285-
if not response.ok:
286-
raise SABaseException(
287-
response.status_code,
288-
"Couldn't change annotation statuses " + response.text
289-
)
290-
logger.info("Annotations status changed")

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.1.0b9"
1+
__version__ = "4.1.0b10"

tests/consensus_benchmark/test_benchmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_benchmark():
3939
)
4040

4141
for annot_type in annot_types:
42+
print(project_name)
4243
res_df = sa.benchmark(
4344
project_name, gt_folder_name, folder_names, annot_type=annot_type
4445
)

0 commit comments

Comments
 (0)