@@ -339,13 +339,27 @@ def __image_upload(
339339
340340 return response
341341
342- def __annotation_upload (self , annotation_path , image_id ):
342+ def __annotation_upload (self , annotation_path : str , image_id : str ):
343343 """function to upload annotation to the specific project
344344 :param annotation_path: path to annotation you'd like to upload
345345 :param image_id: image id you'd like to upload that has annotations for it.
346346 """
347- # Get annotation string
348- annotation_string = open (annotation_path , "r" ).read ()
347+
348+ # check if annotation file exists
349+ if os .path .exists (annotation_path ):
350+ print ("-> found given annotation file" )
351+ annotation_string = open (annotation_path , "r" ).read ()
352+
353+ # if not annotation file, check if user wants to upload regular as classification annotation
354+ elif self .type == "classification" and type (annotation_path ) == str :
355+ print (f"-> using { annotation_path } as classname for classification project" )
356+ annotation_string = annotation_path
357+
358+ # don't attempt upload otherwise
359+ else :
360+ print ("file not found and project type not classification" )
361+ return {"result" : "file not found and project type not classification" }
362+
349363 # Set annotation upload url
350364 self .annotation_upload_url = "" .join (
351365 [
0 commit comments