diverse12 / app.py
Sunghokim's picture
Create app.py
f1127f8 verified
raw
history blame contribute delete
716 Bytes
# app.py
import gradio as gr
from transformers import pipeline
# ๋ชจ๋ธ ๋กœ๋“œ
generator = pipeline('text-to-image', model='CompVis/stable-diffusion-v1-4')
def generate_image(prompt):
# ์ด๋ฏธ์ง€ ์ƒ์„ฑ
images = generator(prompt, num_return_sequences=1)
return images[0]['generated_image']
# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
iface = gr.Interface(
fn=generate_image,
inputs=gr.inputs.Textbox(lines=2, placeholder="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."),
outputs="image",
title="ํ…์ŠคํŠธ์—์„œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ",
description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ํ…์ŠคํŠธ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
)
# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
if __name__ == "__main__":
iface.launch()