Spaces:
Runtime error
Runtime error
File size: 762 Bytes
b4d8bf0 9db0929 c767c81 9db0929 b4d8bf0 9db0929 b4d8bf0 9db0929 |
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 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() |