Skip to content

Commit 3b92a62

Browse files
authored
Merge pull request #412 from roboflow/dataset-upload-are-predictions
Add are_predictions flag to dataset upload to indicate that the dataset is not ground truth and needs review
2 parents c3b9e65 + 9ac6795 commit 3b92a62

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

roboflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from roboflow.models import CLIPModel, GazeModel # noqa: F401
1616
from roboflow.util.general import write_line
1717

18-
__version__ = "1.2.7"
18+
__version__ = "1.2.8"
1919

2020

2121
def check_key(api_key, model, notebook, num_retries=0):

roboflow/core/workspace.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def upload_dataset(
287287
project_type: str = "object-detection",
288288
batch_name=None,
289289
num_retries=0,
290+
is_prediction=False,
290291
):
291292
"""
292293
Upload a dataset to Roboflow.
@@ -298,6 +299,9 @@ def upload_dataset(
298299
dataset_format (str): format of the dataset (`voc`, `yolov8`, `yolov5`)
299300
project_license (str): license of the project (set to `private` for private projects, only available for paid customers)
300301
project_type (str): type of the project (only `object-detection` is supported)
302+
batch_name (str, optional): name of the batch to upload the images to. Defaults to an automatically generated value.
303+
num_retries (int, optional): number of times to retry uploading an image if the upload fails. Defaults to 0.
304+
is_prediction (bool, optional): whether the annotations provided in the dataset are predictions and not ground truth. Defaults to False.
301305
""" # noqa: E501 // docs
302306
if dataset_format != "NOT_USED":
303307
print("Warning: parameter 'dataset_format' is deprecated and will be removed in a future release")
@@ -352,6 +356,7 @@ def _upload_image(imagedesc):
352356
sequence_number=imagedesc.get("index"),
353357
sequence_size=len(images),
354358
num_retry_uploads=num_retries,
359+
is_prediction=is_prediction,
355360
)
356361

357362
return image, upload_time, upload_retry_attempts

tests/test_project.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,50 @@ def test_project_upload_dataset(self):
373373
"params": {},
374374
"assertions": {"save_annotation": {"count": 1}},
375375
},
376+
{
377+
"name": "with_predictions_flag_true",
378+
"dataset": [
379+
{"file": "pred1.jpg", "split": "train", "annotationfile": {"file": "pred1.xml"}},
380+
{"file": "pred2.jpg", "split": "valid", "annotationfile": {"file": "pred2.xml"}},
381+
],
382+
"params": {"is_prediction": True},
383+
"assertions": {
384+
"upload": {"count": 2, "kwargs": {"is_prediction": True}},
385+
"save_annotation": {"count": 2},
386+
},
387+
},
388+
{
389+
"name": "with_predictions_flag_false",
390+
"dataset": [
391+
{"file": "gt1.jpg", "split": "train", "annotationfile": {"file": "gt1.xml"}},
392+
],
393+
"params": {"is_prediction": False},
394+
"assertions": {
395+
"upload": {"count": 1, "kwargs": {"is_prediction": False}},
396+
"save_annotation": {"count": 1},
397+
},
398+
},
399+
{
400+
"name": "predictions_with_batch",
401+
"dataset": [
402+
{"file": "batch_pred.jpg", "split": "train", "annotationfile": {"file": "batch_pred.xml"}},
403+
],
404+
"params": {
405+
"is_prediction": True,
406+
"batch_name": "prediction-batch",
407+
"num_retries": 2,
408+
},
409+
"assertions": {
410+
"upload": {
411+
"count": 1,
412+
"kwargs": {
413+
"is_prediction": True,
414+
"batch_name": "prediction-batch",
415+
"num_retry_uploads": 2,
416+
},
417+
},
418+
},
419+
},
376420
]
377421

378422
error_cases = [

0 commit comments

Comments
 (0)