Spaces:
Runtime error
Runtime error
File size: 1,186 Bytes
1c79e62 60c3317 a7db906 1c79e62 60c3317 bd72465 1c79e62 fe6074f 60c3317 1c79e62 a590af7 1c79e62 a590af7 1c79e62 |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import gradio as gr
#from diffusers import StableDiffusionPipeline
from diffusers import AutoPipelineForText2Image
import torch
#model_id = "runwayml/stable-diffusion-v1-5"
model_id = "stabilityai/sdxl-turbo"
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float32, safety_checker=None)
def infer(prompt):
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt=prompt, guidance_scale=10.0, num_inference_steps=2, width=256, height=256).images[0]
return image
css="""
#col-container {
margin: 0 auto;
max-width: 720px;
}
"""
with gr.Blocks(css=css) as demo:
with gr.Column(elem_id="col-container"):
with gr.Row():
prompt = gr.Text(
label="Prompt",
show_label=False,
max_lines=1,
placeholder="Enter your prompt",
container=False,
)
run_button = gr.Button("Run", scale=0)
result = gr.Image(label="Result", show_label=False)
run_button.click(
fn = infer,
inputs = [prompt],
outputs = [result]
)
demo.queue().launch() |