File size: 1,311 Bytes
622a81e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch
from diffusers import AutoPipelineForText2Image
from diffusers.pipelines.wuerstchen import DEFAULT_STAGE_C_TIMESTEPS
import gradio as gr

if torch.cuda.is_available():
    pipe = AutoPipelineForText2Image.from_pretrained("warp-ai/wuerstchen", torch_dtype=torch.float16).to("cuda")
else:
    pipe = AutoPipelineForText2Image.from_pretrained("warp-ai/wuerstchen")

def gen_image(caption):
    # caption = "Anthropomorphic fox dressed as a fire fighter"
    # fantasy art of a band of brothers human cleric by greg rutkowski
    images = pipe(
        caption,
        width=1024,
        height=1536,
        prior_timesteps=DEFAULT_STAGE_C_TIMESTEPS,
        prior_guidance_scale=4.0,
        num_images_per_prompt=1,
    ).images
    return images[0]


#  Once primed, 1024 x 1536 images are generated in ~6 seconds on my machine; quality is so-so but similar to SD 1.5
with gr.Blocks() as demo:
    gr.Markdown("# Test of the Wueurstchen Model")
    with gr.Row():
        with gr.Column():
            in_text = gr.Textbox(value="Enter a prompt here")
            run_button = gr.Button(variant="primary")
        with gr.Column():
            out_image = gr.Image(label="Image Output")

    run_button.click(gen_image, [in_text], [out_image], None)

if __name__ == '__main__':
    demo.launch()