seawolf2357 commited on
Commit
0669fa1
ยท
verified ยท
1 Parent(s): ed22e5d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Hugging Face ๋ชจ๋ธ ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ
5
+ model = pipeline('image-generation', model='CompVis/dalle-mini')
6
+
7
+ def generate_image(prompt):
8
+ response = model(prompt, return_tensors="pt")
9
+ return response.images[0]
10
+
11
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
12
+ iface = gr.Interface(
13
+ fn=generate_image,
14
+ inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."),
15
+ outputs=gr.outputs.Image(type="pil"),
16
+ title="ํ…์ŠคํŠธ๋ฅผ ์ด๋ฏธ์ง€๋กœ ๋ณ€ํ™˜",
17
+ description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
18
+ )
19
+
20
+ # ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
21
+ iface.launch()