Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import torch | |
| from diffusers import StableDiffusionPipeline | |
| import os | |
| model = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2") | |
| model.to("cuda" if torch.cuda.is_available() else "cpu") | |
| def generate_fabric(prompt: str): | |
| image = model(prompt).images[0] | |
| output_path = "static/generated_texture.jpg" | |
| image.save(output_path) | |
| return output_path | |
| interface = gr.Interface( | |
| fn=generate_fabric, | |
| inputs="text", | |
| outputs="image", | |
| title="AI-Generated Fabric Design", | |
| description="Enter a prompt to generate a custom fabric texture." | |
| ) | |
| if __name__ == "__main__": | |
| interface.launch() | |