Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load the pre-trained model from Hugging Face | |
| model_name = "CompVis/stable-diffusion-v1-4" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16).to("cuda") | |
| def generate_image(prompt): | |
| # Generate image | |
| image = pipe(prompt).images[0] | |
| return image | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_image, | |
| inputs="text", | |
| outputs="image", | |
| title="Image Generation with Stable Diffusion", | |
| description="Generate images from text prompts using Stable Diffusion." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |