Spaces:
Build error
Build error
import spaces | |
import os | |
import torch | |
import gradio as gr | |
from huggingface_hub import login | |
from diffusers import StableDiffusion3Pipeline, DDPMScheduler | |
from dotenv import load_dotenv | |
load_dotenv() | |
login(token=os.getenv("HF_TOKEN")) | |
def generate(): | |
print('start generate') | |
pipeline = StableDiffusion3Pipeline.from_pretrained( | |
"stabilityai/stable-diffusion-3-medium", | |
revision="refs/pr/26", | |
torch_dtype=torch.float16, | |
) | |
pipeline.to("cuda") | |
prompt = "A cat took a fish and running in a market" | |
scheduler = DDPMScheduler(beta_start=0.00085, beta_end=0.012, | |
beta_schedule="scaled_linear") | |
return pipeline( | |
prompt, | |
scheduler=scheduler, | |
num_inference_steps=30, | |
guidance_scale=7.5, | |
).images | |
gr.Interface( | |
fn=generate, | |
inputs=gr.Text(), | |
outputs=gr.Gallery(), | |
).launch() |