Kvikontent's picture
Update app.py
c767c81 verified
raw
history blame
762 Bytes
import gradio as gr
from huggingface_hub import hf_hub_download
from diffusers import DiffusionPipeline
# Load the pre-trained model
model_id = "stabilityai/sdxl-turbo"
model_path = hf_hub_download(repo_id=model_id, repo_type="model")
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float32)
# Define the Gradio interface
def generate_image(prompt):
# Run the diffusion model to generate an image
image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5)
return image
gr_interface = gr.Interface(
fn=generate_image,
inputs="text",
outputs="image",
title="Real-time Image Generation with Diffusion",
description="Enter a prompt to generate an image"
)
# Launch the Gradio app
gr_interface.launch()