@@ -389,6 +389,9 @@ def annotate(
389389
390390 Otherwise, returns an :class:`AsyncJob` object.
391391 """
392+ uploader = AnnotationUploader (dataset_id = self .id , client = self ._client )
393+ uploader .check_for_duplicate_ids (annotations )
394+
392395 if asynchronous :
393396 check_all_mask_paths_remote (annotations )
394397 request_id = serialize_and_write_to_presigned_url (
@@ -399,7 +402,7 @@ def annotate(
399402 route = f"dataset/{ self .id } /annotate?async=1" ,
400403 )
401404 return AsyncJob .from_json (response , self ._client )
402- uploader = AnnotationUploader ( dataset_id = self . id , client = self . _client )
405+
403406 return uploader .upload (
404407 annotations = annotations ,
405408 update = update ,
@@ -1405,6 +1408,14 @@ def upload_predictions(
14051408 "predictions_ignored": int,
14061409 }
14071410 """
1411+ uploader = PredictionUploader (
1412+ model_run_id = None ,
1413+ dataset_id = self .id ,
1414+ model_id = model .id ,
1415+ client = self ._client ,
1416+ )
1417+ uploader .check_for_duplicate_ids (predictions )
1418+
14081419 if asynchronous :
14091420 check_all_mask_paths_remote (predictions )
14101421
@@ -1416,21 +1427,15 @@ def upload_predictions(
14161427 route = f"dataset/{ self .id } /model/{ model .id } /uploadPredictions?async=1" ,
14171428 )
14181429 return AsyncJob .from_json (response , self ._client )
1419- else :
1420- uploader = PredictionUploader (
1421- model_run_id = None ,
1422- dataset_id = self .id ,
1423- model_id = model .id ,
1424- client = self ._client ,
1425- )
1426- return uploader .upload (
1427- annotations = predictions ,
1428- batch_size = batch_size ,
1429- update = update ,
1430- remote_files_per_upload_request = remote_files_per_upload_request ,
1431- local_files_per_upload_request = local_files_per_upload_request ,
1432- local_file_upload_concurrency = local_file_upload_concurrency ,
1433- )
1430+
1431+ return uploader .upload (
1432+ annotations = predictions ,
1433+ batch_size = batch_size ,
1434+ update = update ,
1435+ remote_files_per_upload_request = remote_files_per_upload_request ,
1436+ local_files_per_upload_request = local_files_per_upload_request ,
1437+ local_file_upload_concurrency = local_file_upload_concurrency ,
1438+ )
14341439
14351440 def predictions_iloc (self , model , index ):
14361441 """Fetches all predictions of a dataset item by its absolute index.
0 commit comments