Spaces:
Sleeping
Sleeping
import gradio as gr | |
from diffusers import AutoPipelineForText2Image | |
import torch | |
# Load light pipeline | |
pipe = AutoPipelineForText2Image.from_pretrained( | |
"stabilityai/sdxl-turbo", | |
torch_dtype=torch.float32, | |
low_cpu_mem_usage=True | |
).to("cpu") | |
# Generate image | |
def generate_image(prompt): | |
image = pipe(prompt, num_inference_steps=1, guidance_scale=0.0).images[0] | |
return image | |
# Gradio UI | |
gr.Interface( | |
fn=generate_image, | |
inputs=gr.Textbox(placeholder="A spaceship shaped like a banana..."), | |
outputs="image", | |
title="CJ's CPU-Friendly Image Generator", | |
description="Fast(ish) image generation using SDXL-Turbo on CPU. Magic without the meltdown." | |
).launch() | |