@@ -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
0 commit comments