Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import DiffusionPipeline
|
2 |
+
import torch
|
3 |
import gradio as gr
|
4 |
|
5 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
6 |
+
pipe.to("cuda")
|
7 |
+
|
8 |
+
def greet(prompt):
|
9 |
+
images = pipe(prompt=prompt).images[0]
|
10 |
+
print(images)
|
11 |
+
return images
|
12 |
+
|
13 |
+
demo = gr.Interface(
|
14 |
+
fn=greet,
|
15 |
+
inputs=[
|
16 |
+
gr.Textbox(label="prompt")
|
17 |
+
],
|
18 |
+
outputs=[gr.Image()],
|
19 |
+
api_name="chat",
|
20 |
+
clear_btn=None
|
21 |
+
)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
demo.launch()
|