Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load model | |
| model_id = "openfree/winslow-homer" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
| pipe.to("cuda") | |
| # Inference function | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # Gradio interface | |
| interface = gr.Interface(fn=generate_image, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs=gr.Image(type="pil"), | |
| title="Text to Image Generator", | |
| description="Generate images from your text prompts using Stable Diffusion.") | |
| interface.launch() |