Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
-
import torch
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
use_auth_token=True)
|
8 |
-
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
image = pipe(prompt).images[0]
|
14 |
-
return image
|
15 |
|
16 |
-
# Gradio
|
17 |
iface = gr.Interface(
|
18 |
-
fn=
|
19 |
-
inputs=gr.Textbox(
|
20 |
-
outputs=gr.
|
21 |
)
|
22 |
|
23 |
-
#
|
24 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# ๋ชจ๋ธ์ pipeline์ผ๋ก ์ด๊ธฐํํฉ๋๋ค.
|
5 |
+
text_gen = pipeline("text-generation", model="stabilityai/sdxl-turbo")
|
|
|
|
|
6 |
|
7 |
+
def generate_text(prompt):
|
8 |
+
# ์์ฑ๋ ํ
์คํธ๋ฅผ ๋ฆฌํดํฉ๋๋ค.
|
9 |
+
return text_gen(prompt, max_length=50, do_sample=True)[0]['generated_text']
|
|
|
|
|
10 |
|
11 |
+
# Gradio ์ธํฐํ์ด์ค๋ฅผ ์์ฑํฉ๋๋ค.
|
12 |
iface = gr.Interface(
|
13 |
+
fn=generate_text,
|
14 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a prompt to generate text"),
|
15 |
+
outputs=gr.Textbox(),
|
16 |
)
|
17 |
|
18 |
+
# ์ธํฐํ์ด์ค๋ฅผ ์คํํฉ๋๋ค.
|
19 |
iface.launch()
|