Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,25 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
-
def
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
output = model.generate(input_ids, max_length=50)
|
14 |
-
# ์ถ๋ ฅ ํ
์คํธ ์์ฑ
|
15 |
-
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
16 |
-
return output_text
|
17 |
|
18 |
-
# Gradio
|
19 |
iface = gr.Interface(
|
20 |
-
fn=
|
21 |
-
inputs="
|
22 |
-
outputs="
|
23 |
-
title="
|
24 |
-
description="
|
25 |
)
|
26 |
|
27 |
-
|
|
|
|
|
|
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()
|