@@ -133,7 +133,7 @@ def version(self, version_number):
133133
134134 raise RuntimeError ("Version number {} is not found." .format (version_number ))
135135
136- def __image_upload (self , image_path , hosted_image = False , split = "train" ):
136+ def __image_upload (self , image_path , hosted_image = False , split = "train" , ** kwargs ):
137137 """function to upload image to the specific project
138138 :param image_path: path to image you'd like to upload.
139139 :param hosted_image: if the image is hosted online, then this should be modified
@@ -156,6 +156,8 @@ def __image_upload(self, image_path, hosted_image=False, split="train"):
156156 self .__api_key ,
157157 ]
158158 )
159+ for key , value in kwargs .items ():
160+ self .image_upload_url += "&" + str (key ) + "=" + str (value )
159161
160162 # Convert to PIL Image
161163 img = cv2 .imread (image_path )
@@ -168,12 +170,11 @@ def __image_upload(self, image_path, hosted_image=False, split="train"):
168170
169171 # Build multipart form and post request
170172 m = MultipartEncoder (
171- fields = {
173+ fields = {
172174 "name" : image_name ,
173175 "split" : split ,
174176 "file" : ("imageToUpload" , buffered .getvalue (), "image/jpeg" ),
175- }
176- )
177+ })
177178 response = requests .post (
178179 self .image_upload_url , data = m , headers = {"Content-Type" : m .content_type }
179180 )
@@ -244,6 +245,7 @@ def upload(
244245 image_id = None ,
245246 split = "train" ,
246247 num_retry_uploads = 0 ,
248+ ** kwargs
247249 ):
248250
249251 """upload function
@@ -285,6 +287,7 @@ def upload(
285287 image_id = image_id ,
286288 split = split ,
287289 num_retry_uploads = num_retry_uploads ,
290+ ** kwargs
288291 )
289292 else :
290293 images = os .listdir (image_path )
@@ -298,6 +301,7 @@ def upload(
298301 image_id = image_id ,
299302 split = split ,
300303 num_retry_uploads = num_retry_uploads ,
304+ ** kwargs
301305 )
302306 print ("[ " + path + " ] was uploaded succesfully." )
303307 else :
@@ -312,6 +316,7 @@ def single_upload(
312316 image_id = None ,
313317 split = "train" ,
314318 num_retry_uploads = 0 ,
319+ ** kwargs
315320 ):
316321
317322 success = False
@@ -320,7 +325,7 @@ def single_upload(
320325 if image_path is not None :
321326 # Upload Image Response
322327 response = self .__image_upload (
323- image_path , hosted_image = hosted_image , split = split
328+ image_path , hosted_image = hosted_image , split = split , ** kwargs
324329 )
325330 # Get JSON response values
326331 try :
@@ -360,6 +365,7 @@ def single_upload(
360365 image_id = image_id ,
361366 split = split ,
362367 num_retry_uploads = num_retry_uploads - 1 ,
368+ ** kwargs
363369 )
364370 return
365371 else :
0 commit comments