1212LABELMAPS_EXTENSIONS = {".labels" , ".yaml" , ".yml" }
1313
1414
15+ def _patch_sep (filename ):
16+ """
17+ Replace Windows style slashes to keep filenames consistent.
18+
19+ Roboflow depend on it server side.
20+ """
21+ return filename .replace ("\\ " , "/" )
22+
23+
1524def parsefolder (folder ):
16- folder = folder .strip ()
17- if folder .endswith ("/" ):
18- folder = folder [:- 1 ]
25+ folder = _patch_sep (folder ).strip ().rstrip ("/" )
1926 if not os .path .exists (folder ):
2027 raise Exception (f"folder does not exist. { folder } " )
2128 files = _list_files (folder )
@@ -53,7 +60,9 @@ def _list_files(folder):
5360 for root , dirs , files in os .walk (folder ):
5461 for file in files :
5562 file_path = os .path .join (root , file )
56- filedescriptors .append (_describe_file (file_path .split (folder )[1 ]))
63+ rel = os .path .relpath (file_path , folder )
64+ print ("FILENAME" , file_path , rel )
65+ filedescriptors .append (_describe_file (f"/{ rel } " ))
5766 filedescriptors = sorted (filedescriptors , key = lambda x : _alphanumkey (x ["file" ]))
5867 return filedescriptors
5968
@@ -64,8 +73,8 @@ def _add_indices(files):
6473
6574
6675def _describe_file (f ):
67- name = f . split ( "/" )[ - 1 ]
68- dirname = os . path . dirname ( f )
76+ f = _patch_sep ( f )
77+ dirname , name = f . rsplit ( "/" , 1 )
6978 fullkey , extension = os .path .splitext (f )
7079 fullkey2 = fullkey .replace ("/labels" , "" ).replace ("/images" , "" )
7180 key = os .path .splitext (name )[0 ]
0 commit comments