File size: 7,712 Bytes
3911a99
 
 
 
 
 
 
82fe494
3911a99
 
 
82fe494
 
2204ef0
 
82fe494
2204ef0
 
9f0d168
2204ef0
 
 
 
 
 
 
 
 
 
3911a99
 
 
 
82fe494
3911a99
 
 
 
 
 
 
82fe494
 
3911a99
2204ef0
 
 
3911a99
2204ef0
 
3911a99
 
 
 
 
 
 
2204ef0
 
 
 
3911a99
2204ef0
 
3911a99
 
 
 
 
 
2204ef0
 
 
 
3911a99
9ae63a0
 
3911a99
 
 
 
 
 
9ae63a0
 
 
 
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
 
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
3f7d745
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
3f7d745
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
3f7d745
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
3f7d745
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
 
3f7d745
3911a99
da178ec
82fe494
3911a99
 
 
 
 
 
82fe494
 
739cb0d
82fe494
3911a99
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
from diffusion_webui.controlnet.controlnet_canny import stable_diffusion_controlnet_canny_app, stable_diffusion_controlnet_canny
from diffusion_webui.controlnet.controlnet_depth import stable_diffusion_controlnet_depth_app, stable_diffusion_controlnet_depth
from diffusion_webui.controlnet.controlnet_hed import stable_diffusion_controlnet_hed_app, stable_diffusion_controlnet_hed
from diffusion_webui.controlnet.controlnet_mlsd import stable_diffusion_controlnet_mlsd_app, stable_diffusion_controlnet_mlsd
from diffusion_webui.controlnet.controlnet_pose import stable_diffusion_controlnet_pose_app, stable_diffusion_controlnet_pose
from diffusion_webui.controlnet.controlnet_scribble import stable_diffusion_controlnet_scribble_app, stable_diffusion_controlnet_scribble
from diffusion_webui.controlnet.controlnet_seg import stable_diffusion_controlnet_seg_app, stable_diffusion_controlnet_seg

from diffusion_webui.stable_diffusion.text2img_app import stable_diffusion_text2img_app, stable_diffusion_text2img
from diffusion_webui.stable_diffusion.img2img_app import stable_diffusion_img2img_app, stable_diffusion_img2img
from diffusion_webui.stable_diffusion.inpaint_app import stable_diffusion_inpaint_app, stable_diffusion_inpaint


import gradio as gr


app = gr.Blocks()
with app:
    gr.Markdown("# **<h1 align='center'>Stable Diffusion + ControlNet WebUI<h1>**")
    gr.Markdown(
        """
        <h5 style='text-align: center'>
        Follow me for more! 
        <a href='https://twitter.com/kadirnar_ai' target='_blank'>Twitter</a> | <a href='https://github.com/kadirnar' target='_blank'>Github</a> | <a href='https://www.linkedin.com/in/kadir-nar/' target='_blank'>Linkedin</a>
        </h5>
        """
    )
    with gr.Row():
        with gr.Column():
            text2image_app = stable_diffusion_text2img_app()
            img2img_app = stable_diffusion_img2img_app()
            inpaint_app = stable_diffusion_inpaint_app()
            
            with gr.Tab('ControlNet'):
                controlnet_canny_app = stable_diffusion_controlnet_canny_app()
                controlnet_hed_app = stable_diffusion_controlnet_hed_app()
                controlnet_mlsd_app = stable_diffusion_controlnet_mlsd_app()
                controlnet_depth_app = stable_diffusion_controlnet_depth_app()
                controlnet_pose_app = stable_diffusion_controlnet_pose_app()
                controlnet_scribble_app = stable_diffusion_controlnet_scribble_app()
                controlnet_seg_app = stable_diffusion_controlnet_seg_app()


    with gr.Tab('Output'):
        with gr.Column():
            output_image = gr.Image(label='Image')
            
        text2image_app['predict'].click(
            fn = stable_diffusion_text2img,
            inputs = [
                text2image_app['model_path'],
                text2image_app['prompt'], 
                text2image_app['negative_prompt'], 
                text2image_app['guidance_scale'],
                text2image_app['num_inference_step'], 
                text2image_app['height'],
                text2image_app['width'],
            ],
            outputs = [output_image],
        )  

        img2img_app['predict'].click(
            fn = stable_diffusion_img2img,
            inputs = [
                img2img_app['image_path'],
                img2img_app['model_path'], 
                img2img_app['prompt'], 
                img2img_app['negative_prompt'],
                img2img_app['guidance_scale'], 
                img2img_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  

        inpaint_app['predict'].click(
            fn = stable_diffusion_inpaint,
            inputs = [
                inpaint_app['image_path'],
                inpaint_app['model_path'], 
                inpaint_app['prompt'], 
                inpaint_app['negative_prompt'],
                inpaint_app['guidance_scale'], 
                inpaint_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  

        controlnet_canny_app['predict'].click(
            fn = stable_diffusion_controlnet_canny,
            inputs = [
                controlnet_canny_app['image_path'],
                controlnet_canny_app['model_path'], 
                controlnet_canny_app['prompt'], 
                controlnet_canny_app['negative_prompt'],
                controlnet_canny_app['guidance_scale'], 
                controlnet_canny_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  

        controlnet_hed_app['predict'].click(
            fn = stable_diffusion_controlnet_hed,
            inputs = [
                controlnet_hed_app['image_path'],
                controlnet_hed_app['model_path'], 
                controlnet_hed_app['prompt'], 
                controlnet_hed_app['negative_prompt'],
                controlnet_hed_app['guidance_scale'], 
                controlnet_hed_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  
        
        controlnet_mlsd_app['predict'].click(
            fn = stable_diffusion_controlnet_mlsd,
            inputs = [
                controlnet_mlsd_app['image_path'],
                controlnet_mlsd_app['model_path'], 
                controlnet_mlsd_app['prompt'], 
                controlnet_mlsd_app['negative_prompt'],
                controlnet_mlsd_app['guidance_scale'], 
                controlnet_mlsd_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  
        
        controlnet_depth_app['predict'].click(
            fn = stable_diffusion_controlnet_seg,
            inputs = [
                controlnet_depth_app['image_path'],
                controlnet_depth_app['model_path'], 
                controlnet_depth_app['prompt'], 
                controlnet_depth_app['negative_prompt'],
                controlnet_depth_app['guidance_scale'], 
                controlnet_depth_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  
        
        controlnet_pose_app['predict'].click(
            fn = stable_diffusion_controlnet_depth,
            inputs = [
                controlnet_pose_app['image_path'],
                controlnet_pose_app['model_path'], 
                controlnet_pose_app['prompt'], 
                controlnet_pose_app['negative_prompt'],
                controlnet_pose_app['guidance_scale'], 
                controlnet_pose_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  
        
        controlnet_scribble_app['predict'].click(
            fn = stable_diffusion_controlnet_scribble,
            inputs = [
                controlnet_scribble_app['image_path'],
                controlnet_scribble_app['model_path'], 
                controlnet_scribble_app['prompt'], 
                controlnet_scribble_app['negative_prompt'],
                controlnet_scribble_app['guidance_scale'], 
                controlnet_scribble_app['num_inference_step'],
            ],
            outputs = [output_image],
        )  
        
        controlnet_seg_app['predict'].click(
            fn = stable_diffusion_controlnet_pose,
            inputs = [
                controlnet_seg_app['image_path'],
                controlnet_seg_app['model_path'], 
                controlnet_seg_app['prompt'], 
                controlnet_seg_app['negative_prompt'],
                controlnet_seg_app['guidance_scale'], 
                controlnet_seg_app['num_inference_step'],
            ],
            outputs = [output_image],
        )

app.launch(debug=True)