Spaces:
Running
Running
import gradio as gr | |
# ์ด๋ฏธ์ง ์์ฑ ํจ์๋ค import | |
from animagine_xl import generate_animagine_xl | |
from animesai import generate_animesai | |
from generate_sdxl_with_refiner import generate_sdxl_with_refiner | |
from ghibli import generate_ghibli | |
from realistic import generate_realistic | |
from sd_turbo import generate_sd_turbo | |
from waifu import generate_waifu | |
# ํ๊ตญ์ด ์ด์ผ๊ธฐ ์์ฑ ํจ์ import | |
from Text2Long_text import generate_korean_story | |
# ๋ชจ๋ธ ํจ์ ๋งคํ | |
MODEL_FUNCTIONS = { | |
"Animagine XL": generate_animagine_xl, | |
"Animesai": generate_animesai, | |
"SDXL+Refiner": generate_sdxl_with_refiner, | |
"Ghibli": generate_ghibli, | |
"Realistic": generate_realistic, | |
"SD Turbo": generate_sd_turbo, | |
"Waifu Diffusion": generate_waifu, | |
"ํ๊ตญ์ด ๊ธด ์ด์ผ๊ธฐ ์์ฑ": lambda prompt: generate_korean_story(prompt, max_length=500), | |
} | |
def generate_selected_results(prompt, selected_models): | |
results = [] | |
for name in selected_models: | |
gen_func = MODEL_FUNCTIONS.get(name) | |
if gen_func: | |
result = gen_func(prompt) | |
results.append((name, result)) | |
# ๊ฒฐ๊ณผ๋ณ๋ก ์ ์ ํ ๊ตฌ๋ถ(์ด๋ฏธ์ง๋ gallery์ฉ, ํ ์คํธ๋ ์๋์ ํ์) | |
images = [] | |
texts = [] | |
for name, result in results: | |
if hasattr(result, "save") or hasattr(result, "show"): | |
images.append(result) # PIL.Image๋ก ๊ฐ์ฃผ | |
else: | |
texts.append(f"[{name}]\n{result}") | |
return images, "\n\n".join(texts) | |
with gr.Blocks() as demo: | |
gr.Markdown("## ์ํ๋ ์์ฑ ๋ชจ๋ธ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๊ฑฐ๋, ๊ธด ํ๊ตญ์ด ์ด์ผ๊ธฐ๋ฅผ ๋ฐ์๋ณด์ธ์") | |
prompt = gr.Textbox(label="ํ๋กฌํํธ(ํ ์คํธ๋ฅผ ์ ๋ ฅํ์ธ์)") | |
models = gr.CheckboxGroup( | |
choices=list(MODEL_FUNCTIONS.keys()), | |
label="์ฌ์ฉํ ๋ชจ๋ธ์ ์ ํํ์ธ์" | |
) | |
gallery = gr.Gallery(label="์์ฑ ์ด๋ฏธ์ง (์ ํํ ๋ชจ๋ธ๋ณ)").style(grid=3) | |
long_textbox = gr.Textbox(label="์์ฑ๋ ์ด์ผ๊ธฐ(ํ ์คํธ)", lines=10, interactive=False) | |
generate_btn = gr.Button("์์ฑํ๊ธฐ") | |
generate_btn.click( | |
fn=generate_selected_results, | |
inputs=[prompt, models], | |
outputs=[gallery, long_textbox] | |
) | |
demo.launch() | |