Spaces:
Sleeping
Sleeping
File size: 633 Bytes
e7b6575 46fd450 e7b6575 4f9d074 e7b6575 46fd450 4f9d074 46fd450 e7b6575 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
model_id = "stabilityai/sd-turbo"
pipe = StableDiffusionPipeline.from_pretrained(
model_id,
torch_dtype=torch.float32
)
pipe = pipe.to("cpu")
pipe.enable_attention_slicing()
pipe.enable_vae_slicing()
torch.set_float32_matmul_precision("high")
def generate(prompt):
image = pipe(
prompt,
height=240,
width=240,
num_inference_steps=4,
guidance_scale=0.0
).images[0]
return image
gr.Interface(
fn=generate,
inputs=gr.Textbox(label="Prompt"),
outputs=gr.Image(type="pil")
).launch()
|