Skip to content

Commit c0b6bf0

Browse files
authored
Merge pull request #114 from roboflow/upload-with-tag
added tag_name on upload
2 parents 57b7aa7 + 02ebfd4 commit c0b6bf0

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

roboflow/core/project.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def __image_upload(
262262
hosted_image=False,
263263
split="train",
264264
batch_name=DEFAULT_BATCH_NAME,
265+
tag_names=[],
265266
**kwargs,
266267
):
267268
"""function to upload image to the specific project
@@ -296,6 +297,9 @@ def __image_upload(
296297
for key, value in kwargs.items():
297298
self.image_upload_url += "&" + str(key) + "=" + str(value)
298299

300+
for tag in tag_names:
301+
self.image_upload_url = self.image_upload_url + f"&tag={tag}"
302+
299303
# Convert to PIL Image
300304
img = cv2.imread(image_path)
301305
image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
@@ -376,21 +380,30 @@ def check_valid_image(self, image_path):
376380

377381
def upload(
378382
self,
379-
image_path=None,
380-
annotation_path=None,
381-
hosted_image=False,
382-
image_id=None,
383-
split="train",
384-
num_retry_uploads=0,
385-
batch_name=DEFAULT_BATCH_NAME,
383+
image_path: str = None,
384+
annotation_path: str = None,
385+
hosted_image: bool = False,
386+
image_id: int = None,
387+
split: str = "train",
388+
num_retry_uploads: int = 0,
389+
batch_name: str = DEFAULT_BATCH_NAME,
390+
tag_names: list = [],
386391
**kwargs,
387392
):
388-
"""upload function
389-
:param image_path: path to image you'd like to upload
390-
:param annotation_path: if you're upload annotation, path to it
391-
:param hosted_image: whether the image is hosted
392-
:param image_id: id of the image
393-
:param split: split to upload the image to
393+
"""Upload image function based on the RESTful API
394+
395+
Args:
396+
image_path (str) - path to image you'd like to upload
397+
annotation_path (str) - if you're upload annotation, path to it
398+
hosted_image (bool) - whether the image is hosted
399+
image_id (int) - id of the image
400+
split (str) - to upload the image to
401+
num_retry_uploads (int) - how many times to retry upload on failure
402+
batch_name (str) - name of batch to upload to within project
403+
tag_names (list[str]) - tags to be applied to an image
404+
405+
Returns:
406+
None - returns nothing
394407
"""
395408

396409
is_hosted = image_path.startswith("http://") or image_path.startswith(
@@ -425,6 +438,7 @@ def upload(
425438
split=split,
426439
num_retry_uploads=num_retry_uploads,
427440
batch_name=batch_name,
441+
tag_names=tag_names,
428442
**kwargs,
429443
)
430444
else:
@@ -440,6 +454,7 @@ def upload(
440454
split=split,
441455
num_retry_uploads=num_retry_uploads,
442456
batch_name=batch_name,
457+
tag_names=tag_names,
443458
**kwargs,
444459
)
445460
print("[ " + path + " ] was uploaded succesfully.")
@@ -456,6 +471,7 @@ def single_upload(
456471
split="train",
457472
num_retry_uploads=0,
458473
batch_name=DEFAULT_BATCH_NAME,
474+
tag_names=[],
459475
**kwargs,
460476
):
461477
success = False
@@ -468,6 +484,7 @@ def single_upload(
468484
hosted_image=hosted_image,
469485
split=split,
470486
batch_name=batch_name,
487+
tag_names=tag_names,
471488
**kwargs,
472489
)
473490
# Get JSON response values

roboflow/core/workspace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ def active_learning(
368368
and prediction["confidence"] * 100
369369
<= conditionals["confidence_interval"][1]
370370
):
371-
372371
# filter out non-target_class uploads if enabled
373372
if (
374373
len(conditionals["target_classes"]) > 0

roboflow/models/object_detection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def __generate_url(
214214
labels=None,
215215
format=None,
216216
):
217-
218217
# Reassign parameters if any parameters are changed
219218
if local is not None:
220219
if not local:

roboflow/util/two_stage_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
def ocr_infer(image):
10-
1110
# Convert to JPEG Buffer
1211
buffered = io.BytesIO()
1312
image.save(buffered, quality=90, format="PNG")

roboflow/util/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def print_warn_for_wrong_dependencies_versions(
4545
dependencies_versions: List[Tuple[str, str, str]]
4646
):
4747
wrong_dependencies_versions = get_wrong_dependencies_versions(dependencies_versions)
48-
for (dependency, order, version, module_version) in wrong_dependencies_versions:
48+
for dependency, order, version, module_version in wrong_dependencies_versions:
4949
print(
5050
f"Dependency {dependency}{order}{version} is required but found version={module_version}, to fix: `pip install {dependency}{order}{version}`"
5151
)

0 commit comments

Comments
 (0)