Spaces:
Build error
Build error
Commit
·
ca4f7e4
1
Parent(s):
f19e129
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from optimum.intel.openvino import OVStableDiffusionPipeline
|
| 3 |
+
from diffusers.training_utils import set_seed
|
| 4 |
+
|
| 5 |
+
quantized_pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/Stable-Diffusion-Pokemon-en-quantized", compile=False)
|
| 6 |
+
quantized_pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
|
| 7 |
+
quantized_pipe.compile()
|
| 8 |
+
|
| 9 |
+
prompt = "cartoon bird"
|
| 10 |
+
|
| 11 |
+
def generate(image):
|
| 12 |
+
output = pipe(prompt, num_inference_steps=50, output_type="pil")
|
| 13 |
+
return output.images[0]
|
| 14 |
+
|
| 15 |
+
gr.Interface(
|
| 16 |
+
fn=generate,
|
| 17 |
+
inputs=gr.inputs.Textbox(placeholder="cartoon bird",
|
| 18 |
+
label="Prompt"
|
| 19 |
+
"query",
|
| 20 |
+
lines=1),
|
| 21 |
+
outputs=gr.outputs.Image(type="auto", label="Generated Image"),
|
| 22 |
+
title="Quantized stable diffusion",
|
| 23 |
+
description="",
|
| 24 |
+
theme="huggingface",
|
| 25 |
+
).launch()
|