File size: 6,408 Bytes
e5d376a
fbd37eb
418b8a3
f1470af
 
 
6eb5e1e
ddca435
418b8a3
ba9035e
418b8a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbd37eb
7ed14c7
f1470af
 
 
 
aec1a03
63c5c46
 
f1470af
63c5c46
b9f80c9
f1470af
ba9035e
 
f1470af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddca435
6eb5e1e
5d2a4e3
 
6eb5e1e
713298e
5d2a4e3
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import streamlit as st
import shutil
import os 
from PIL import Image
import requests

from gradio_client import Client

prompt_prefix = "night, full body, closed mouth, happy face, walking front, "
prompt_list = [
    "loli, onepiece dress, white dress, sleeveless",
    "loli, onepiece dress, white dress, sleeveless, white belt",
    "loli, onepiece dress, white dress, sleeveless, white belt, white ribbon",
    "loli, onepiece dress, white dress, sleeveless, white belt, white ribbon, white sock",
    "loli, onepiece dress, white dress, sleeveless, white belt, white ribbon, white sock, white shoes",
    "loli, onepiece dress, white dress, sleeveless, black belt, white ribbon, white sock, white shoes",
    "loli, onepiece dress, white dress, sleeveless, black belt, red ribbon, white sock, white shoes",
    "loli, onepiece dress, white dress, sleeveless, black belt, red ribbon, white sock, black shoes",
    "loli, onepiece dress, white dress, sleeveless, black belt, red ribbon, white sock, black shoes, white skirt",
    "loli, onepiece dress, white dress, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt",
    "loli, onepiece dress, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt",
    "loli, elementary school dress, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt",
    "loli, elementary school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt",
    "loli, elementary school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt, white collar",
    "loli, elementary school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, white skirt, white collar, sailor collar",
    "loli, elementary school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, blue skirt, white collar, sailor collar",
    "loli, middle school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, blue skirt, white collar, sailor collar",
    "loli, middle school uniform, white clothes, short sleeve, black belt, red ribbon, white sock, black shoes, blue skirt, blue collar, sailor collar",
    "loli, middle school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, blue collar, sailor collar",
    "loli, middle school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, sailor collar",
    "loli, middle school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, formal collar",
    "middle school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, formal collar",
    "high school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, formal collar",
    "high school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, formal collar, blazer",
    "high school uniform, white clothes, short sleeve, black belt, red necktie, white sock, black shoes, blue skirt, white collar, formal collar, black blazer",
    ]
prompt_suffix = ", masterpiece, best quality, very aesthetic, absurdres"
if os.path.exists("./output/") == False:
    os.mkdir("./output/")
if os.path.exists("./frames/") == False:
    os.mkdir("./frames/")
if os.path.exists("./interpolations/") == False:
    os.mkdir("./interpolations/")
project_name = str(st.text_input("Project name")).replace(" ", "-")
character = st.text_input("character")
anime_from = st.text_input("From")
seed = st.number_input('seed')
if st.button("Generate!"):
    client = Client("cagliostrolab/animagine-xl-3.1")
    n = 0
    for p in prompt_list:
        prompt_new = "1girl, "+character+", "+anime_from+", "+prompt_prefix+p+prompt_suffix
        result = client.predict(
	    	prompt_new,	# str  in 'Prompt' Textbox component
		    "nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]",	# str  in 'Negative Prompt' Textbox component
	    	seed,	# float (numeric value between 0 and 2147483647) in 'Seed' Slider component
	    	768,	# float (numeric value between 512 and 2048) in 'Width' Slider component
	    	1344,	# float (numeric value between 512 and 2048) in 'Height' Slider component
	    	7,	# float (numeric value between 1 and 12) in 'Guidance scale' Slider component
	    	28,	# float (numeric value between 1 and 50) in 'Number of inference steps' Slider component
	    	"Euler a",	# Literal['DPM++ 2M Karras', 'DPM++ SDE Karras', 'DPM++ 2M SDE Karras', 'Euler', 'Euler a', 'DDIM']  in 'Sampler' Dropdown component
	    	"768 x 1344",	# Literal['1024 x 1024', '1152 x 896', '896 x 1152', '1216 x 832', '832 x 1216', '1344 x 768', '768 x 1344', '1536 x 640', '640 x 1536', 'Custom']  in 'Aspect Ratio' Radio component
	    	"(None)",	# Literal['(None)', 'Cinematic', 'Photographic', 'Anime', 'Manga', 'Digital Art', 'Pixel art', 'Fantasy art', 'Neonpunk', '3D Model']  in 'Style Preset' Radio component
	    	"Standard v3.1",	# Literal['(None)', 'Standard v3.0', 'Standard v3.1', 'Light v3.1', 'Heavy v3.1']  in 'Quality Tags Presets' Dropdown component
	    	False,	# bool  in 'Use Upscaler' Checkbox component
	    	0,	# float (numeric value between 0 and 1) in 'Strength' Slider component
	    	1,	# float (numeric value between 1 and 1.5) in 'Upscale by' Slider component
	    	True,	# bool  in 'Add Quality Tags' Checkbox component
	    	api_name="/run"
        )
        source = 'https://cagliostrolab-animagine-xl-3-1.hf.space/file='+result[0][0]["image"]
        frame = Image.open(requests.get(source, stream=True).raw)
        frame.save("./output/"+str(n)+".png")
        n += 1
        print(source)
    
output_num = len(os.listdir("./output/"))
if output_num > 0:
    archived = shutil.make_archive("output", 'zip', "./output/")
    st.download_button(label="Download "+str(output_num)+" file", data=archived, file_name='output.zip', mime='application/x-zip')

print(os.listdir("./"))