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("./"))