@@ -346,7 +346,9 @@ def __image_upload(
346346
347347 return response
348348
349- def __annotation_upload (self , annotation_path : str , image_id : str ):
349+ def __annotation_upload (
350+ self , annotation_path : str , image_id : str , is_prediction : bool = False
351+ ):
350352 """function to upload annotation to the specific project
351353 :param annotation_path: path to annotation you'd like to upload
352354 :param image_id: image id you'd like to upload that has annotations for it.
@@ -389,6 +391,7 @@ def __annotation_upload(self, annotation_path: str, image_id: str):
389391 "?api_key=" ,
390392 self .__api_key ,
391393 "&name=" + os .path .basename (annotation_path ),
394+ "&is_prediction=true" if is_prediction else "" ,
392395 ]
393396 )
394397
@@ -422,6 +425,7 @@ def upload(
422425 num_retry_uploads : int = 0 ,
423426 batch_name : str = DEFAULT_BATCH_NAME ,
424427 tag_names : list = [],
428+ is_prediction : bool = False ,
425429 ** kwargs ,
426430 ):
427431 """Upload image function based on the RESTful API
@@ -435,6 +439,7 @@ def upload(
435439 num_retry_uploads (int) - how many times to retry upload on failure
436440 batch_name (str) - name of batch to upload to within project
437441 tag_names (list[str]) - tags to be applied to an image
442+ is_prediction (bool) - whether the annotation data is a prediction rather than ground truth
438443
439444 Returns:
440445 None - returns nothing
@@ -473,8 +478,10 @@ def upload(
473478 num_retry_uploads = num_retry_uploads ,
474479 batch_name = batch_name ,
475480 tag_names = tag_names ,
481+ is_prediction = is_prediction ,
476482 ** kwargs ,
477483 )
484+
478485 else :
479486 images = os .listdir (image_path )
480487 for image in images :
@@ -489,6 +496,7 @@ def upload(
489496 num_retry_uploads = num_retry_uploads ,
490497 batch_name = batch_name ,
491498 tag_names = tag_names ,
499+ is_prediction = is_prediction ,
492500 ** kwargs ,
493501 )
494502 print ("[ " + path + " ] was uploaded succesfully." )
@@ -506,6 +514,7 @@ def single_upload(
506514 num_retry_uploads = 0 ,
507515 batch_name = DEFAULT_BATCH_NAME ,
508516 tag_names = [],
517+ is_prediction : bool = False ,
509518 ** kwargs ,
510519 ):
511520 success = False
@@ -572,7 +581,9 @@ def single_upload(
572581 # Upload only annotations to image based on image Id (no image)
573582 if annotation_path is not None and image_id is not None and success :
574583 # Get annotation upload response
575- annotation_response = self .__annotation_upload (annotation_path , image_id )
584+ annotation_response = self .__annotation_upload (
585+ annotation_path , image_id , is_prediction = is_prediction
586+ )
576587 # Check if upload was a success
577588 try :
578589 response_data = annotation_response .json ()
0 commit comments