File size: 735 Bytes
0669fa1
 
30fd9a1
 
 
 
 
0669fa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from transformers import pipeline

# ๋ณ€๊ฒฝ๋œ ์ฝ”๋“œ: Stable Diffusion ๋ชจ๋ธ ์‚ฌ์šฉ
model = pipeline('text-to-image', model='CompVis/stable-diffusion-v1-4')

# ์ด๋ฏธ์ง€ ์ƒ์„ฑ ์˜ˆ์‹œ
generated_images = model("A cute puppy sitting on the moon")

def generate_image(prompt):
    response = model(prompt, return_tensors="pt")
    return response.images[0]

# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
iface = gr.Interface(
    fn=generate_image,
    inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."),
    outputs=gr.outputs.Image(type="pil"),
    title="ํ…์ŠคํŠธ๋ฅผ ์ด๋ฏธ์ง€๋กœ ๋ณ€ํ™˜",
    description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
)

# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
iface.launch()