Spaces:
Runtime error
Runtime error
File size: 631 Bytes
0a11297 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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()
|