@@ -175,19 +175,21 @@ def _reload_tag_model(self):
175175
176176 with tag_path .open ("r" , encoding = "utf-8" ) as f :
177177 csv_reader = csv .reader (f )
178- # skip header line
179- next (csv_reader )
180178 for tag , type_str , count , _aliases in csv_reader :
181- tag = tag .replace ("_" , " " )
182- tag_type = TagType (int (type_str ))
183- count = int (count )
184- count_str = str (count )
185- if count > 1_000_000 :
186- count_str = f"{ count / 1_000_000 :.0f} m"
187- elif count > 1_000 :
188- count_str = f"{ count / 1_000 :.0f} k"
189- meta = f"{ tag_name } { count_str } "
190- all_tags .append (TagItem (tag , tag_type , count , meta ))
179+ if type_str .isdigit (): # skip header rows if they exist
180+ tag = tag .replace ("_" , " " )
181+ try :
182+ tag_type = TagType (int (type_str ))
183+ except : # default to general category if category is not recognised
184+ tag_type = TagType (0 )
185+ count = int (count )
186+ count_str = str (count )
187+ if count > 1_000_000 :
188+ count_str = f"{ count / 1_000_000 :.0f} m"
189+ elif count > 1_000 :
190+ count_str = f"{ count / 1_000 :.0f} k"
191+ meta = f"{ tag_name } { count_str } "
192+ all_tags .append (TagItem (tag , tag_type , count , meta ))
191193
192194 sorted_tags = sorted (all_tags , key = lambda x : x .count , reverse = True )
193195 seen = set ()
0 commit comments