|
import gradio as gr |
|
from diffusers import AutoPipelineForText2Image |
|
import torch |
|
|
|
|
|
def generate_image(prompt): |
|
|
|
pipe = AutoPipelineForText2Image.from_pretrained( |
|
"stabilityai/sdxl-turbo", |
|
torch_dtype=torch.float32 |
|
) |
|
pipe = pipe.to("cpu") |
|
|
|
|
|
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0] |
|
return image |
|
|
|
|
|
interface = gr.Interface( |
|
fn=generate_image, |
|
inputs=gr.Textbox(label="Enter a description for the image"), |
|
outputs=gr.Image(type="pil", label="Generated Image"), |
|
title="Image Generator", |
|
description="This interface generates images based on your descriptions using the Stability AI SDXL-Turbo model." |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
interface.launch() |
|
|