Spaces:
Runtime error
Runtime error
import gradio as gr | |
import torch | |
from diffusers import DiffusionPipeline | |
device = "cuda" if torch.cuda.is_available() else "cpu" | |
pipe = DiffusionPipeline.from_pretrained( | |
"stabilityai/stable-diffusion-xl-base-1.0", | |
torch_dtype=torch.float16 if device == "cuda" else torch.float32, | |
use_safetensors=True, | |
) | |
pipe.to(device) | |
def generate(prompt): | |
image = pipe(prompt=prompt).images[0] | |
return image | |
gr.Interface( | |
fn=generate, | |
inputs=gr.Textbox(label="Prompt", placeholder="A painting of a cat in Van Gogh style"), | |
outputs=gr.Image(label="Generated Image"), | |
title="SDXL Free Generator" | |
).launch() | |