File size: 820 Bytes
3daf324 b4406cf 3daf324 de62ac6 3daf324 |
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
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() |