@@ -538,8 +538,13 @@ def upload_images_from_folder_to_project(
538538 )
539539
540540
541+ def create_empty_annotation (size ):
542+ return {"metadata" : {'height' : size [1 ], 'width' : size [0 ]}}
543+
544+
541545def upload_image_array_to_s3 (
542- bucket , size , orig_image , lores_image , huge_image , thumbnail_image , key
546+ bucket , size , orig_image , lores_image , huge_image , thumbnail_image , key ,
547+ project_type
543548):
544549 bucket .put_object (Body = orig_image , Key = key )
545550 bucket .put_object (Body = lores_image , Key = key + '___lores.jpg' )
@@ -552,6 +557,10 @@ def upload_image_array_to_s3(
552557 }
553558 )
554559 bucket .put_object (Body = thumbnail_image , Key = key + '___thumb.jpg' )
560+ postfix_json = '___objects.json' if project_type == "Vector" else '___pixel.json'
561+ bucket .put_object (
562+ Body = json .dumps (create_empty_annotation (size )), Key = key + postfix_json
563+ )
555564
556565
557566def get_image_array_to_upload (
@@ -657,7 +666,9 @@ def __upload_images_to_aws_thread(
657666 images_array = get_image_array_to_upload (
658667 file , image_quality_in_editor , project ["type" ]
659668 )
660- upload_image_array_to_s3 (bucket , * images_array , key )
669+ upload_image_array_to_s3 (
670+ bucket , * images_array , key , project ["type" ]
671+ )
661672 except Exception as e :
662673 logger .warning ("Unable to upload image %s. %s" , path , e )
663674 couldnt_upload [thread_id ].append (path )
@@ -1191,8 +1202,8 @@ def upload_annotations_from_folder_to_project(
11911202 :param recursive_subfolders: enable recursive subfolder parsing
11921203 :type recursive_subfolders: bool
11931204
1194- :return: paths to annotations uploaded
1195- :rtype: list of strs
1205+ :return: paths to annotations uploaded, could-not-upload, missing-images
1206+ :rtype: tuple of list of strs
11961207 """
11971208 if recursive_subfolders :
11981209 logger .info (
@@ -1439,6 +1450,7 @@ def __tqdm_thread_upload_annotations(
14391450 pbar .update (total_num - pbar .n )
14401451 break
14411452
1453+
14421454def __tqdm_thread_upload_preannotations (
14431455 total_num , uploaded , couldnt_upload , finish_event
14441456):
@@ -1480,8 +1492,8 @@ def upload_preannotations_from_folder_to_project(
14801492 :param recursive_subfolders: enable recursive subfolder parsing
14811493 :type recursive_subfolders: bool
14821494
1483- :return: paths to pre-annotations uploaded
1484- :rtype: list of strs
1495+ :return: paths to pre-annotations uploaded and could-not-upload
1496+ :rtype: tuple of list of strs
14851497 """
14861498 if recursive_subfolders :
14871499 logger .info (
@@ -1583,7 +1595,6 @@ def _upload_preannotations_from_folder_to_project(
15831595 finish_event = threading .Event ()
15841596 tqdm_thread = threading .Thread (
15851597 target = __tqdm_thread_upload_preannotations ,
1586-
15871598 args = (len_preannotations_paths , couldnt_upload , uploaded , finish_event ),
15881599 daemon = True
15891600 )
@@ -1627,7 +1638,6 @@ def _upload_preannotations_from_folder_to_project(
16271638 for file in upload_thread :
16281639 list_of_uploaded .append (str (file ))
16291640 return (list_of_uploaded , list_of_not_uploaded )
1630- return return_result + [str (p ) for p in preannotations_paths ]
16311641
16321642
16331643def share_project (project , user , user_role ):
0 commit comments