Vivien Chappelier commited on
Commit
d2794b1
1 Parent(s): 0b00c74

stable diffusion v2 on CPU

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1,8 +1,17 @@
1
  import gradio as gr
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
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