Spaces:
Sleeping
Sleeping
File size: 551 Bytes
36e7af4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
# Load model
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float32
)
pipe.to("cpu") # Spaces free tier uses CPU
def generate(prompt):
image = pipe(prompt).images[0]
return image
gr.Interface(
fn=generate,
inputs=gr.Textbox(label="Enter your prompt"),
outputs="image",
title="Stable Diffusion Generator",
description="Generate images from text using Stable Diffusion"
).launch() |