Spaces:
Runtime error
Runtime error
File size: 654 Bytes
bd62f93 |
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
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()
|