@@ -41,7 +41,7 @@ def dump_yaml_and_check_difference(obj, file):
4141
4242 if osp .isfile (file ):
4343 file_exists = True
44- print (f' exist { file } ' )
44+ # print(f' exist {file}')
4545 with open (file , 'r' , encoding = 'utf-8' ) as f :
4646 str_orig = f .read ()
4747 else :
@@ -144,20 +144,26 @@ def parse_md(md_file):
144144 Name = collection_name ,
145145 Metadata = {'Architecture' : []},
146146 README = readme ,
147- Paper = [])
147+ Paper = [],
148+ Task = [],
149+ Year = 0 ,
150+ )
148151 models = []
149152 # force utf-8 instead of system defined
150153 with open (md_file , 'r' , encoding = 'utf-8' ) as md :
151154 lines = md .readlines ()
152155 i = 0
153156 name = lines [0 ][2 :]
157+ year = re .sub ('[^0-9]' , '' , name .split ('(' , 1 )[- 1 ])
154158 name = name .split ('(' , 1 )[0 ].strip ()
155159 collection ['Metadata' ]['Architecture' ].append (name )
156160 collection ['Name' ] = name
157161 collection_name = name
158162 is_liif = collection_name .upper () == 'LIIF'
159163 task_line = lines [4 ]
160164 task = task_line .strip ().split (':' )[- 1 ].strip ()
165+ collection ['Task' ] = task .lower ().split (', ' )
166+ collection ['Year' ] = int (year )
161167 while i < len (lines ):
162168 # parse reference
163169 if lines [i ].startswith ('> [' ):
@@ -177,16 +183,19 @@ def parse_md(md_file):
177183 # import ipdb
178184 # ipdb.set_trace()
179185 if 'Config' not in cols and 'Download' not in cols :
180- warnings .warn (f"Lack 'Config' or 'Download' in line { i + 1 } " )
186+ warnings .warn ("Lack 'Config' or 'Download' in"
187+ f'line { i + 1 } in { md_file } ' )
181188 i += 1
182189 continue
190+
183191 if 'Method' in cols :
184192 config_idx = cols .index ('Method' )
185193 elif 'Config' in cols :
186194 config_idx = cols .index ('Config' )
187195 else :
188196 print (cols )
189197 raise ValueError ('Cannot find config Table.' )
198+
190199 checkpoint_idx = cols .index ('Download' )
191200 try :
192201 flops_idx = cols .index ('FLOPs' )
@@ -210,6 +219,8 @@ def parse_md(md_file):
210219 left = line [config_idx ].index ('](' ) + 2
211220 right = line [config_idx ].index (')' , left )
212221 config = line [config_idx ][left :right ].strip ('./' )
222+ config = osp .join (
223+ osp .dirname (md_file ), osp .basename (config ))
213224 elif line [config_idx ].find ('△' ) == - 1 :
214225 j += 1
215226 continue
@@ -315,7 +326,7 @@ def parse_md(md_file):
315326 i += 1
316327
317328 if len (models ) == 0 :
318- warnings .warn ('no model is found in this md file ' )
329+ warnings .warn (f 'no model is found in { md_file } ' )
319330
320331 result = {'Collections' : [collection ], 'Models' : models }
321332 yml_file = md_file .replace ('README.md' , 'metafile.yml' )
@@ -363,9 +374,11 @@ def update_model_index():
363374 sys .exit (0 )
364375
365376 file_modified = False
377+ # pbar = tqdm.tqdm(range(len(file_list)), initial=0, dynamic_ncols=True)
366378 for fn in file_list :
367- print (f'process { fn } ' )
368379 file_modified |= parse_md (fn )
380+ # pbar.update(1)
381+ # pbar.set_description(f'processing {fn}')
369382
370383 file_modified |= update_model_index ()
371384
0 commit comments