Skip to content

Commit 9c0f240

Browse files
committed
add is_prediction parameter to upload functions
1 parent 1c37df3 commit 9c0f240

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

roboflow/core/project.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def __image_upload(
346346

347347
return response
348348

349-
def __annotation_upload(self, annotation_path: str, image_id: str):
349+
def __annotation_upload(self, annotation_path: str, image_id: str, is_prediction: bool = False):
350350
"""function to upload annotation to the specific project
351351
:param annotation_path: path to annotation you'd like to upload
352352
:param image_id: image id you'd like to upload that has annotations for it.
@@ -389,6 +389,7 @@ def __annotation_upload(self, annotation_path: str, image_id: str):
389389
"?api_key=",
390390
self.__api_key,
391391
"&name=" + os.path.basename(annotation_path),
392+
"&is_prediction=true" if is_prediction else ""
392393
]
393394
)
394395

@@ -422,6 +423,7 @@ def upload(
422423
num_retry_uploads: int = 0,
423424
batch_name: str = DEFAULT_BATCH_NAME,
424425
tag_names: list = [],
426+
is_prediction: bool = False,
425427
**kwargs,
426428
):
427429
"""Upload image function based on the RESTful API
@@ -435,6 +437,7 @@ def upload(
435437
num_retry_uploads (int) - how many times to retry upload on failure
436438
batch_name (str) - name of batch to upload to within project
437439
tag_names (list[str]) - tags to be applied to an image
440+
is_prediction (bool) - whether the annotation data is a prediction rather than ground truth
438441
439442
Returns:
440443
None - returns nothing
@@ -473,6 +476,7 @@ def upload(
473476
num_retry_uploads=num_retry_uploads,
474477
batch_name=batch_name,
475478
tag_names=tag_names,
479+
is_prediction=is_prediction,
476480
**kwargs,
477481
)
478482
else:
@@ -489,6 +493,7 @@ def upload(
489493
num_retry_uploads=num_retry_uploads,
490494
batch_name=batch_name,
491495
tag_names=tag_names,
496+
is_prediction=is_prediction
492497
**kwargs,
493498
)
494499
print("[ " + path + " ] was uploaded succesfully.")
@@ -506,6 +511,7 @@ def single_upload(
506511
num_retry_uploads=0,
507512
batch_name=DEFAULT_BATCH_NAME,
508513
tag_names=[],
514+
is_prediction: bool = False,
509515
**kwargs,
510516
):
511517
success = False
@@ -572,7 +578,7 @@ def single_upload(
572578
# Upload only annotations to image based on image Id (no image)
573579
if annotation_path is not None and image_id is not None and success:
574580
# Get annotation upload response
575-
annotation_response = self.__annotation_upload(annotation_path, image_id)
581+
annotation_response = self.__annotation_upload(annotation_path, image_id, is_prediction=is_prediction)
576582
# Check if upload was a success
577583
try:
578584
response_data = annotation_response.json()

0 commit comments

Comments
 (0)