CoolFace
Apppublic

HIST/ControlNet

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
gradio_hed2image.py69 linesDownload Raw Back to root
1# This file is adapted from https://github.com/lllyasviel/ControlNet/blob/f4748e3630d8141d7765e2bd9b1e348f47847707/gradio_hed2image.py2# The original license file is LICENSE.ControlNet this repo.3import gradio as gr4 5 6def create_demo(process):7    with gr.Blocks() as demo:8        with gr.Row():9            gr.Markdown('## Control Stable Diffusion with HED Maps')10        with gr.Row():11            with gr.Column():12                input_image = gr.Image(source='upload', type='numpy')13                prompt = gr.Textbox(label='Prompt')14                run_button = gr.Button(label='Run')15                with gr.Accordion('Advanced options', open=False):16                    num_samples = gr.Slider(label='Images',17                                            minimum=1,18                                            maximum=12,19                                            value=1,20                                            step=1)21                    image_resolution = gr.Slider(label='Image Resolution',22                                                 minimum=256,23                                                 maximum=768,24                                                 value=512,25                                                 step=256)26                    detect_resolution = gr.Slider(label='HED Resolution',27                                                  minimum=128,28                                                  maximum=1024,29                                                  value=512,30                                                  step=1)31                    ddim_steps = gr.Slider(label='Steps',32                                           minimum=1,33                                           maximum=100,34                                           value=20,35                                           step=1)36                    scale = gr.Slider(label='Guidance Scale',37                                      minimum=0.1,38                                      maximum=30.0,39                                      value=9.0,40                                      step=0.1)41                    seed = gr.Slider(label='Seed',42                                     minimum=-1,43                                     maximum=2147483647,44                                     step=1,45                                     randomize=True)46                    eta = gr.Number(label='eta (DDIM)', value=0.0)47                    a_prompt = gr.Textbox(48                        label='Added Prompt',49                        value='best quality, extremely detailed')50                    n_prompt = gr.Textbox(51                        label='Negative Prompt',52                        value=53                        'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality'54                    )55            with gr.Column():56                result_gallery = gr.Gallery(label='Output',57                                            show_label=False,58                                            elem_id='gallery').style(59                                                grid=2, height='auto')60        ips = [61            input_image, prompt, a_prompt, n_prompt, num_samples,62            image_resolution, detect_resolution, ddim_steps, scale, seed, eta63        ]64        run_button.click(fn=process,65                         inputs=ips,66                         outputs=[result_gallery],67                         api_name='hed')68    return demo69