| import csv | |
| import json | |
| # Télécharge selected_tags.csv depuis https://huggingface.co/SmilingWolf/wd-v1-4-vit-tagger-v2/resolve/main/selected_tags.csv | |
| with open('selected_tags.csv', 'r', encoding='utf-8') as f: | |
| reader = csv.DictReader(f) | |
| tags = [] | |
| for row in reader: | |
| if row['category'] == '0': # General tags only | |
| tags.append(row['name']) | |
| with open('tags.json', 'w', encoding='utf-8') as f: | |
| json.dump(tags, f, ensure_ascii=False) | |
| print(f"General tags only : {len(tags)} tags") | |
| print("Exemples : ", tags[:10]) |