|
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, |
|
"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]", |
|
seed, |
|
768, |
|
1344, |
|
7, |
|
28, |
|
"Euler a", |
|
"768 x 1344", |
|
"(None)", |
|
"Standard v3.1", |
|
False, |
|
0, |
|
1, |
|
True, |
|
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("./")) |