AlexKoff88's picture
Update app.py
b85f1a6
raw
history blame
1.11 kB
import gradio as gr
from optimum.intel.openvino import OVStableDiffusionPipeline
from diffusers.training_utils import set_seed
quantized_pipe = OVStableDiffusionPipeline.from_pretrained("OpenVINO/Stable-Diffusion-Pokemon-en-quantized", compile=False)
quantized_pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
quantized_pipe.compile()
prompt = "cartoon bird"
def generate(image):
output = quantized_pipe(prompt, num_inference_steps=50, output_type="pil")
return output.images[0]
examples = ["cartoon bird",
"a drawing of a green pokemon with red eyes",
"plant pokemon in jungle"]
gr.Interface(
fn=generate,
inputs=gr.inputs.Textbox(placeholder="cartoon bird",
label="Prompt",
lines=1),
outputs=gr.outputs.Image(type="pil", label="Generated Image"),
title="OpenVINO-optimized Stable Diffusion",
description="This is the Optimum-based demo for optimized Stable Diffusion pipeline trained on Pokemon dataset and running with OpenVINO",
theme="huggingface",
).launch()