Sunghokim commited on
Commit
f1127f8
ยท
verified ยท
1 Parent(s): b7f72a3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ # ๋ชจ๋ธ ๋กœ๋“œ
7
+ generator = pipeline('text-to-image', model='CompVis/stable-diffusion-v1-4')
8
+
9
+ def generate_image(prompt):
10
+ # ์ด๋ฏธ์ง€ ์ƒ์„ฑ
11
+ images = generator(prompt, num_return_sequences=1)
12
+ return images[0]['generated_image']
13
+
14
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
15
+ iface = gr.Interface(
16
+ fn=generate_image,
17
+ inputs=gr.inputs.Textbox(lines=2, placeholder="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."),
18
+ outputs="image",
19
+ title="ํ…์ŠคํŠธ์—์„œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ",
20
+ description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ•ด๋‹น ํ…์ŠคํŠธ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
21
+ )
22
+
23
+ # ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
24
+ if __name__ == "__main__":
25
+ iface.launch()