Spaces:
Running
on
T4
Running
on
T4
Vivien Chappelier
commited on
Commit
•
d2794b1
1
Parent(s):
0b00c74
stable diffusion v2 on CPU
Browse files
app.py
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def greet(name):
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="
|
7 |
iface.launch()
|
8 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from optimum.intel.openvino import OVStableDiffusionPipeline
|
3 |
+
|
4 |
+
pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/stable-diffusion-2-1-quantized", compile=False)
|
5 |
+
pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
|
6 |
+
pipe.compile()
|
7 |
+
|
8 |
+
prompt = "sailing ship in storm by Rembrandt"
|
9 |
|
10 |
def greet(name):
|
11 |
+
output = pipe(prompt, num_inference_steps=50, output_type="pil")
|
12 |
+
output.images[0].save("result.png")
|
13 |
+
return output.images[0]
|
14 |
|
15 |
+
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Prompt", default=prompt)], outputs=[gr.Image(type="pil")])
|
16 |
iface.launch()
|
17 |
|