@@ -64,14 +64,14 @@ def projects(self):
6464
6565 return projects_array
6666
67- def project (self , project_name ):
67+ def project (self , project_id ):
6868 """
6969 Retrieve a Project() object that represents a project in the workspace.
7070
7171 This object can be used to retrieve the model through which to run inference.
7272
7373 Args:
74- project_name (str): name of the project
74+ project_id (str): id of the project
7575
7676 Returns:
7777 Project Object
@@ -83,17 +83,17 @@ def project(self, project_name):
8383 if self .__api_key in DEMO_KEYS :
8484 return Project (self .__api_key , {}, self .model_format )
8585
86- project_name = project_name .replace (self .url + "/" , "" )
86+ # project_id = project_id .replace(self.url + "/", "")
8787
88- if "/" in project_name :
88+ if "/" in project_id :
8989 raise RuntimeError (
9090 "The {} project is not available in this ({}) workspace" .format (
91- project_name , self .url
91+ project_id , self .url
9292 )
9393 )
9494
9595 dataset_info = requests .get (
96- API_URL + "/" + self .url + "/" + project_name + "?api_key=" + self .__api_key
96+ API_URL + "/" + self .url + "/" + project_id + "?api_key=" + self .__api_key
9797 )
9898
9999 # Throw error if dataset isn't valid/user doesn't have permissions to access the dataset
@@ -333,7 +333,7 @@ def _upload_dataset_auto(
333333 ):
334334 parsed_dataset = folderparser .parsefolder (dataset_path )
335335 project , created = self ._get_or_create_project (
336- project_name , license = project_license , type = project_type
336+ project_id = project_name , license = project_license , type = project_type
337337 )
338338 if created :
339339 print (f"Created project { project .id } " )
@@ -371,6 +371,7 @@ def _upload_image(imagedesc):
371371 image_path = f"{ location } { imagedesc ['file' ]} "
372372 split = imagedesc ["split" ]
373373 annotation_path = None
374+ labelmap = None
374375 annotationdesc = imagedesc .get ("annotationfile" )
375376 if annotationdesc :
376377 annotation_path = f"{ location } { annotationdesc ['file' ]} "
@@ -390,20 +391,17 @@ def _upload_image(imagedesc):
390391 list (executor .map (_upload_image , images ))
391392
392393 def _get_or_create_project (
393- self , project_name , license : str = "MIT" , type : str = "object-detection"
394+ self , project_id , license : str = "MIT" , type : str = "object-detection"
394395 ):
395- found_project = next (
396- (p for p in self .project_list if p ["name" ] == project_name ), None
397- )
398- if found_project :
399- project_url = found_project ["id" ].split ("/" )[1 ]
400- return self .project (project_url ), False
401- else :
396+ try :
397+ existing_project = self .project (project_id )
398+ return existing_project , False
399+ except RuntimeError :
402400 return (
403401 self .create_project (
404- project_name ,
402+ project_name = project_id ,
405403 project_license = license ,
406- annotation = project_name ,
404+ annotation = project_id ,
407405 project_type = type ,
408406 ),
409407 True ,
@@ -426,7 +424,6 @@ def _upload_dataset_legacy(
426424 raise Exception (
427425 "dataset_format not supported - please use voc, yolov8, yolov5. PS, you can always convert your dataset in the Roboflow UI"
428426 )
429-
430427 # check type stuff and convert
431428 if dataset_format == "yolov8" or dataset_format == "yolov5" :
432429 # convert to voc
0 commit comments