Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
def
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
# Gradio
|
| 12 |
iface = gr.Interface(
|
| 13 |
-
fn=
|
| 14 |
-
inputs=gr.Textbox(
|
| 15 |
-
outputs=
|
| 16 |
)
|
| 17 |
|
| 18 |
-
#
|
| 19 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
# ๋ชจ๋ธ ์ด๊ธฐํ
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",
|
| 7 |
+
use_auth_token=True)
|
| 8 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
+
# ํ
์คํธ ํ๋กฌํํธ๋ก๋ถํฐ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ํจ์
|
| 11 |
+
def generate_image(prompt):
|
| 12 |
+
with torch.autocast("cuda"):
|
| 13 |
+
image = pipe(prompt).images[0]
|
| 14 |
+
return image
|
| 15 |
|
| 16 |
+
# Gradio ์ธํฐํ์ด์ค ์ ์
|
| 17 |
iface = gr.Interface(
|
| 18 |
+
fn=generate_image,
|
| 19 |
+
inputs=gr.Textbox(label="Enter a prompt for the AI to generate an image"),
|
| 20 |
+
outputs=gr.Image(type="pil"),
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# ์ธํฐํ์ด์ค ์คํ
|
| 24 |
iface.launch()
|