aboutsummaryrefslogtreecommitdiff
path: root/scripts/create_inspiration_images.py
blob: 6a20def8298b65d028d241c8f4dccc88ea31e704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import csv, os, shutil
import modules.scripts as scripts
from modules import processing, shared, sd_samplers, images
from modules.processing import Processed


class Script(scripts.Script):
    def title(self):
        return "Create artists style image"

    def show(self, is_img2img):
        return not is_img2img

    def ui(self, is_img2img):
       return []
    def show(self, is_img2img):
        return not is_img2img

    def run(self, p): #, max_snapshoots_num):
        path = os.path.join("style_snapshoot", "artist")
        if not os.path.exists(path):
            os.makedirs(path) 
        p.do_not_save_samples = True
        p.do_not_save_grid = True
        p.negative_prompt = "portrait photo"
        f = open('artists.csv')
        f_csv = csv.reader(f)        
        for row in f_csv:
            name = row[0]
            artist_path = os.path.join(path, name)  
            if not os.path.exists(artist_path):
                os.mkdir(artist_path)  
            if len(os.listdir(artist_path)) > 0:
                continue
            print(name)
            p.prompt = name
            processed = processing.process_images(p)
            for img in  processed.images:
                i = 0
                filename = os.path.join(artist_path,  format(0, "03d") + ".jpg")
                while os.path.exists(filename):
                    i += 1
                    filename = os.path.join(artist_path,  format(i, "03d") + ".jpg")
                img.save(filename, quality=70)
        return processed