CoolFace
Apppublic

cymic/Waifu_Diffusion_Webui

sourceHugging Faceupdated 4y agoView on Hugging Face
1likes
artists.py26 linesDownload Raw Back to modules
1import os.path2import csv3from collections import namedtuple4 5Artist = namedtuple("Artist", ['name', 'weight', 'category'])6 7 8class ArtistsDatabase:9    def __init__(self, filename):10        self.cats = set()11        self.artists = []12 13        if not os.path.exists(filename):14            return15 16        with open(filename, "r", newline='', encoding="utf8") as file:17            reader = csv.DictReader(file)18 19            for row in reader:20                artist = Artist(row["artist"], float(row["score"]), row["category"])21                self.artists.append(artist)22                self.cats.add(artist.category)23 24    def categories(self):25        return sorted(self.cats)26