File size: 1,597 Bytes
80e89cb
43bcc57
80e89cb
b507d13
80e89cb
 
 
 
 
 
43bcc57
80e89cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43bcc57
80e89cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
import gradio as gr 
import spaces

import torch
from pipeline_diffusehigh_sdxl import DiffuseHighSDXLPipeline
pipeline = DiffuseHighSDXLPipeline.from_pretrained(
        "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16,
).to("cuda")


@spaces.GPU()
def process_(
    prompt="",
    target_height=[1536, 2048],
    target_width=[1536, 2048],
):
    negative_prompt = "blurry, ugly, duplicate, poorly drawn, deformed, mosaic"

    image = pipeline(
            prompt,
            negative_prompt=negative_prompt,
            target_height=target_height,
            target_width=target_width,
            enable_dwt=True,
            dwt_steps=5,
            enable_sharpening=True,
            sharpness_factor=1.0,
        ).images[0]

    return image
    
def create_demo():
    with gr.Blocks(theme="bethecloud/storj_theme") as demo:
        with gr.Row():
            with gr.Column():
                prompt = gr.Textbox(label="Prompt", value="A cat holding a sign that says hello world")
                generate_button = gr.Button("Generate")
            
            with gr.Column():
                output_image = gr.Image(label="Generated Image")

        generate_button.click(
            fn=process_,
            inputs=[prompt],
            outputs=[output_image]
        )
        
        examples = [
            "a tiny astronaut hatching from an egg on the moon",
            "a cat holding a sign that says hello world",
            "an anime illustration of a wiener schnitzel",
        ]

    return demo

demo = create_demo()
demo.launch(share=True)