File size: 880 Bytes
ca4f7e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 = pipe(prompt, num_inference_steps=50, output_type="pil")
    return output.images[0]

gr.Interface(
    fn=generate,
    inputs=gr.inputs.Textbox(placeholder="cartoon bird", 
                             label="Prompt"
                             "query",
                             lines=1),
    outputs=gr.outputs.Image(type="auto", label="Generated Image"),
    title="Quantized stable diffusion",
    description="",
    theme="huggingface",
).launch()