Create app.py
Browse files
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()
|