File size: 2,384 Bytes
d2677d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e46fd7d
 
777ee0f
e46fd7d
777ee0f
e46fd7d
 
 
 
d2677d3
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
import gradio as gr

def create_demo(process):
    block = gr.Blocks().queue()
    with block:
        with gr.Row():
            with gr.Column():
                input_img = gr.Image(source='upload', type="numpy")
                prompt = gr.Textbox(label="Prompt")
                neg_prompt = gr.Textbox(label="Negative Prompt",
                value='ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face')
                run_button = gr.Button(label="Run")
                with gr.Accordion("Advanced options", open=False):
                    con_strength = gr.Slider(label="Controling Strength (The guidance strength of the sketch to the result)", minimum=0, maximum=1, value=0.4, step=0.1)
                    scale = gr.Slider(label="Guidance Scale (Classifier free guidance)", minimum=0.1, maximum=30.0, value=7.5, step=0.1)
                    fix_sample = gr.inputs.Radio(['True', 'False'], type="value", default='False', label='Fix Sampling\n (Fix the random seed)')
                    base_model = gr.inputs.Radio(['sd-v1-4.ckpt', 'anything-v4.0-pruned.ckpt'], type="value", default='sd-v1-4.ckpt', label='The base model you want to use')
            with gr.Column():
                result = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
            ips = [input_img,prompt, neg_prompt, fix_sample, scale, con_strength, base_model]
        run_button.click(fn=process, inputs=ips, outputs=[result])

        examples_list = [["iron.png", "iron man, cyberpunk",
                         "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face",
                         'True',
                         7.5,
                        0.4,
                        'sd-v1-4.ckpt']]

        examples = gr.Examples(examples=examples_list,inputs = [input_img, prompt,neg_prompt, fix_sample, scale, con_strength,base_model], outputs = [result], cache_examples = True, fn = process)

    return block