oai / convert.py
Skarn55's picture
Upload 2 files
29e7e4f verified
raw
history blame
563 Bytes
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])