|
17 | 17 | ) |
18 | 18 | from ..api import API |
19 | 19 | from ..common import ( |
20 | | - annotation_status_str_to_int, deprecated_alias, hex_to_rgb, |
21 | | - image_path_to_annotation_paths, project_type_int_to_str |
| 20 | + annotation_status_str_to_int, hex_to_rgb, image_path_to_annotation_paths, |
| 21 | + project_type_int_to_str |
22 | 22 | ) |
23 | 23 | from ..exceptions import SABaseException |
24 | 24 | from .annotation_classes import ( |
@@ -201,9 +201,7 @@ def add_annotation_comment_to_image( |
201 | 201 | comment_author, |
202 | 202 | resolved=resolved |
203 | 203 | ) |
204 | | - upload_annotations_from_json_to_image( |
205 | | - project, image_name, annotations, verbose=False |
206 | | - ) |
| 204 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
207 | 205 |
|
208 | 206 |
|
209 | 207 | def add_annotation_bbox_to_image( |
@@ -239,9 +237,7 @@ def add_annotation_bbox_to_image( |
239 | 237 | annotation_class_attributes, |
240 | 238 | error, |
241 | 239 | ) |
242 | | - upload_annotations_from_json_to_image( |
243 | | - project, image_name, annotations, verbose=False |
244 | | - ) |
| 240 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
245 | 241 |
|
246 | 242 |
|
247 | 243 | def add_annotation_polygon_to_image( |
@@ -275,9 +271,7 @@ def add_annotation_polygon_to_image( |
275 | 271 | annotations, polygon, annotation_class_name, |
276 | 272 | annotation_class_attributes, error |
277 | 273 | ) |
278 | | - upload_annotations_from_json_to_image( |
279 | | - project, image_name, annotations, verbose=False |
280 | | - ) |
| 274 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
281 | 275 |
|
282 | 276 |
|
283 | 277 | def add_annotation_polyline_to_image( |
@@ -310,9 +304,7 @@ def add_annotation_polyline_to_image( |
310 | 304 | annotations, polyline, annotation_class_name, |
311 | 305 | annotation_class_attributes, error |
312 | 306 | ) |
313 | | - upload_annotations_from_json_to_image( |
314 | | - project, image_name, annotations, verbose=False |
315 | | - ) |
| 307 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
316 | 308 |
|
317 | 309 |
|
318 | 310 | def add_annotation_point_to_image( |
@@ -345,9 +337,7 @@ def add_annotation_point_to_image( |
345 | 337 | annotations, point, annotation_class_name, annotation_class_attributes, |
346 | 338 | error |
347 | 339 | ) |
348 | | - upload_annotations_from_json_to_image( |
349 | | - project, image_name, annotations, verbose=False |
350 | | - ) |
| 340 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
351 | 341 |
|
352 | 342 |
|
353 | 343 | def add_annotation_ellipse_to_image( |
@@ -380,9 +370,7 @@ def add_annotation_ellipse_to_image( |
380 | 370 | annotations, ellipse, annotation_class_name, |
381 | 371 | annotation_class_attributes, error |
382 | 372 | ) |
383 | | - upload_annotations_from_json_to_image( |
384 | | - project, image_name, annotations, verbose=False |
385 | | - ) |
| 373 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
386 | 374 |
|
387 | 375 |
|
388 | 376 | def add_annotation_template_to_image( |
@@ -422,9 +410,7 @@ def add_annotation_template_to_image( |
422 | 410 | annotations, template_points, template_connections, |
423 | 411 | annotation_class_name, annotation_class_attributes, error |
424 | 412 | ) |
425 | | - upload_annotations_from_json_to_image( |
426 | | - project, image_name, annotations, verbose=False |
427 | | - ) |
| 413 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
428 | 414 |
|
429 | 415 |
|
430 | 416 | def add_annotation_cuboid_to_image( |
@@ -460,9 +446,7 @@ def add_annotation_cuboid_to_image( |
460 | 446 | annotations, cuboid, annotation_class_name, annotation_class_attributes, |
461 | 447 | error |
462 | 448 | ) |
463 | | - upload_annotations_from_json_to_image( |
464 | | - project, image_name, annotations, verbose=False |
465 | | - ) |
| 449 | + upload_image_annotations(project, image_name, annotations, verbose=False) |
466 | 450 |
|
467 | 451 |
|
468 | 452 | def download_image( |
@@ -628,9 +612,7 @@ def get_image_preannotations(project, image_name): |
628 | 612 | raise SABaseException(response.status_code, response.text) |
629 | 613 | res = response.json() |
630 | 614 |
|
631 | | - annotation_classes = search_annotation_classes( |
632 | | - project |
633 | | - ) |
| 615 | + annotation_classes = search_annotation_classes(project) |
634 | 616 | annotation_classes_dict = get_annotation_classes_id_to_name( |
635 | 617 | annotation_classes |
636 | 618 | ) |
@@ -724,9 +706,7 @@ def get_image_annotations(project, image_name, project_type=None): |
724 | 706 | raise SABaseException(response.status_code, response.text) |
725 | 707 | res = response.json() |
726 | 708 |
|
727 | | - annotation_classes = search_annotation_classes( |
728 | | - project |
729 | | - ) |
| 709 | + annotation_classes = search_annotation_classes(project) |
730 | 710 | annotation_classes_dict = get_annotation_classes_id_to_name( |
731 | 711 | annotation_classes |
732 | 712 | ) |
@@ -853,8 +833,7 @@ def download_image_preannotations(project, image_name, local_dir_path): |
853 | 833 | return tuple(return_filepaths) |
854 | 834 |
|
855 | 835 |
|
856 | | -@deprecated_alias(mask_path="mask") |
857 | | -def upload_annotations_from_json_to_image( |
| 836 | +def upload_image_annotations( |
858 | 837 | project, image_name, annotation_json, mask=None, verbose=True |
859 | 838 | ): |
860 | 839 | """Upload annotations from JSON (also mask for pixel annotations) |
@@ -886,9 +865,7 @@ def upload_annotations_from_json_to_image( |
886 | 865 | "Uploading annotations for image %s in project %s.", image_name, |
887 | 866 | project["name"] |
888 | 867 | ) |
889 | | - annotation_classes = search_annotation_classes( |
890 | | - project |
891 | | - ) |
| 868 | + annotation_classes = search_annotation_classes(project) |
892 | 869 | annotation_classes_dict = get_annotation_classes_name_to_id( |
893 | 870 | annotation_classes |
894 | 871 | ) |
|
0 commit comments