OPENVINO / app.py
tejani's picture
Update app.py
b4406cf verified
raw
history blame
820 Bytes
import gradio as gr
from optimum.intel.openvino import OVStableDiffusionPipeline
import torch
# Load the quantized model from Hugging Face
model_id = "Intel/sd-1.5-square-quantized"
pipe = OVStableDiffusionPipeline.from_pretrained(model_id, export=False, library_name="diffusers")
# Define the inference function
def generate_image(prompt):
# Generate the image
image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5).images[0]
return image
# Create the Gradio interface
interface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=gr.Image(label="Generated Image"),
title="Stable Diffusion 1.5 Square Quantized Demo",
description="Generate square images using Intel's quantized SD 1.5 model."
)
# Launch the interface
interface.launch()