Spaces:
Paused
Paused
Upload 32 files
Browse files- app.py +7 -4
- diffusion_webui/__init__.py +30 -1
- diffusion_webui/app.py +77 -0
- diffusion_webui/diffusion_models/controlnet/__init__.py +8 -0
- diffusion_webui/diffusion_models/controlnet/controlnet_inpaint/__init__.py +7 -0
- diffusion_webui/diffusion_models/controlnet/controlnet_mlsd.py +11 -4
- diffusion_webui/diffusion_models/controlnet/controlnet_normal.py +190 -0
- diffusion_webui/diffusion_models/stable_diffusion/__init__.py +3 -0
- diffusion_webui/helpers.py +12 -41
- diffusion_webui/utils/model_list.py +9 -4
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
from diffusion_webui
|
4 |
CodeformerUpscalerGenerator,
|
5 |
StableDiffusionControlInpaintNetDepthGenerator,
|
6 |
StableDiffusionControlNetCannyGenerator,
|
@@ -19,10 +19,11 @@ from diffusion_webui.helpers import (
|
|
19 |
StableDiffusionImage2ImageGenerator,
|
20 |
StableDiffusionInpaintGenerator,
|
21 |
StableDiffusionText2ImageGenerator,
|
|
|
22 |
)
|
23 |
|
24 |
|
25 |
-
def
|
26 |
app = gr.Blocks()
|
27 |
with app:
|
28 |
with gr.Row():
|
@@ -46,6 +47,8 @@ def main():
|
|
46 |
StableDiffusionControlNetPoseGenerator.app()
|
47 |
with gr.Tab("Scribble"):
|
48 |
StableDiffusionControlNetScribbleGenerator.app()
|
|
|
|
|
49 |
with gr.Tab("Seg"):
|
50 |
StableDiffusionControlNetSegGenerator.app()
|
51 |
with gr.Tab("ControlNet Inpaint"):
|
@@ -66,9 +69,9 @@ def main():
|
|
66 |
with gr.Tab("Upscaler"):
|
67 |
CodeformerUpscalerGenerator.app()
|
68 |
|
69 |
-
app.queue(concurrency_count=
|
70 |
app.launch(debug=True, enable_queue=True)
|
71 |
|
72 |
|
73 |
if __name__ == "__main__":
|
74 |
-
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from diffusion_webui import (
|
4 |
CodeformerUpscalerGenerator,
|
5 |
StableDiffusionControlInpaintNetDepthGenerator,
|
6 |
StableDiffusionControlNetCannyGenerator,
|
|
|
19 |
StableDiffusionImage2ImageGenerator,
|
20 |
StableDiffusionInpaintGenerator,
|
21 |
StableDiffusionText2ImageGenerator,
|
22 |
+
StableDiffusionControlNetNormalGenerator,
|
23 |
)
|
24 |
|
25 |
|
26 |
+
def diffusion_app():
|
27 |
app = gr.Blocks()
|
28 |
with app:
|
29 |
with gr.Row():
|
|
|
47 |
StableDiffusionControlNetPoseGenerator.app()
|
48 |
with gr.Tab("Scribble"):
|
49 |
StableDiffusionControlNetScribbleGenerator.app()
|
50 |
+
with gr.Tab("Normal"):
|
51 |
+
StableDiffusionControlNetNormalGenerator.app()
|
52 |
with gr.Tab("Seg"):
|
53 |
StableDiffusionControlNetSegGenerator.app()
|
54 |
with gr.Tab("ControlNet Inpaint"):
|
|
|
69 |
with gr.Tab("Upscaler"):
|
70 |
CodeformerUpscalerGenerator.app()
|
71 |
|
72 |
+
app.queue(concurrency_count=2)
|
73 |
app.launch(debug=True, enable_queue=True)
|
74 |
|
75 |
|
76 |
if __name__ == "__main__":
|
77 |
+
diffusion_app()
|
diffusion_webui/__init__.py
CHANGED
@@ -1 +1,30 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusion_webui.diffusion_models.stable_diffusion import (
|
2 |
+
StableDiffusionText2ImageGenerator,
|
3 |
+
StableDiffusionImage2ImageGenerator,
|
4 |
+
StableDiffusionInpaintGenerator,
|
5 |
+
)
|
6 |
+
|
7 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint import (
|
8 |
+
StableDiffusionControlNetInpaintCannyGenerator,
|
9 |
+
StableDiffusionControlInpaintNetDepthGenerator,
|
10 |
+
StableDiffusionControlNetInpaintHedGenerator,
|
11 |
+
StableDiffusionControlNetInpaintMlsdGenerator,
|
12 |
+
StableDiffusionControlNetInpaintPoseGenerator,
|
13 |
+
StableDiffusionControlNetInpaintScribbleGenerator,
|
14 |
+
StableDiffusionControlNetInpaintSegGenerator,
|
15 |
+
)
|
16 |
+
|
17 |
+
from diffusion_webui.diffusion_models.controlnet import (
|
18 |
+
StableDiffusionControlNetCannyGenerator,
|
19 |
+
StableDiffusionControlNetDepthGenerator,
|
20 |
+
StableDiffusionControlNetHEDGenerator,
|
21 |
+
StableDiffusionControlNetMLSDGenerator,
|
22 |
+
StableDiffusionControlNetNormalGenerator,
|
23 |
+
StableDiffusionControlNetPoseGenerator,
|
24 |
+
StableDiffusionControlNetScribbleGenerator,
|
25 |
+
StableDiffusionControlNetSegGenerator,
|
26 |
+
)
|
27 |
+
|
28 |
+
from diffusion_webui.app import diffusion_app as app
|
29 |
+
|
30 |
+
__version__ = "2.2.0"
|
diffusion_webui/app.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from diffusion_webui import (
|
4 |
+
CodeformerUpscalerGenerator,
|
5 |
+
StableDiffusionControlInpaintNetDepthGenerator,
|
6 |
+
StableDiffusionControlNetCannyGenerator,
|
7 |
+
StableDiffusionControlNetDepthGenerator,
|
8 |
+
StableDiffusionControlNetHEDGenerator,
|
9 |
+
StableDiffusionControlNetInpaintCannyGenerator,
|
10 |
+
StableDiffusionControlNetInpaintHedGenerator,
|
11 |
+
StableDiffusionControlNetInpaintMlsdGenerator,
|
12 |
+
StableDiffusionControlNetInpaintPoseGenerator,
|
13 |
+
StableDiffusionControlNetInpaintScribbleGenerator,
|
14 |
+
StableDiffusionControlNetInpaintSegGenerator,
|
15 |
+
StableDiffusionControlNetMLSDGenerator,
|
16 |
+
StableDiffusionControlNetPoseGenerator,
|
17 |
+
StableDiffusionControlNetScribbleGenerator,
|
18 |
+
StableDiffusionControlNetSegGenerator,
|
19 |
+
StableDiffusionImage2ImageGenerator,
|
20 |
+
StableDiffusionInpaintGenerator,
|
21 |
+
StableDiffusionText2ImageGenerator,
|
22 |
+
StableDiffusionControlNetNormalGenerator,
|
23 |
+
)
|
24 |
+
|
25 |
+
|
26 |
+
def diffusion_app():
|
27 |
+
app = gr.Blocks()
|
28 |
+
with app:
|
29 |
+
with gr.Row():
|
30 |
+
with gr.Column():
|
31 |
+
with gr.Tab("Text2Img"):
|
32 |
+
StableDiffusionText2ImageGenerator.app()
|
33 |
+
with gr.Tab("Img2Img"):
|
34 |
+
StableDiffusionImage2ImageGenerator.app()
|
35 |
+
with gr.Tab("Inpaint"):
|
36 |
+
StableDiffusionInpaintGenerator.app()
|
37 |
+
with gr.Tab("ControlNet"):
|
38 |
+
with gr.Tab("Canny"):
|
39 |
+
StableDiffusionControlNetCannyGenerator.app()
|
40 |
+
with gr.Tab("Depth"):
|
41 |
+
StableDiffusionControlNetDepthGenerator.app()
|
42 |
+
with gr.Tab("HED"):
|
43 |
+
StableDiffusionControlNetHEDGenerator.app()
|
44 |
+
with gr.Tab("MLSD"):
|
45 |
+
StableDiffusionControlNetMLSDGenerator.app()
|
46 |
+
with gr.Tab("Pose"):
|
47 |
+
StableDiffusionControlNetPoseGenerator.app()
|
48 |
+
with gr.Tab("Scribble"):
|
49 |
+
StableDiffusionControlNetScribbleGenerator.app()
|
50 |
+
with gr.Tab("Normal"):
|
51 |
+
StableDiffusionControlNetNormalGenerator.app()
|
52 |
+
with gr.Tab("Seg"):
|
53 |
+
StableDiffusionControlNetSegGenerator.app()
|
54 |
+
with gr.Tab("ControlNet Inpaint"):
|
55 |
+
with gr.Tab("Canny"):
|
56 |
+
StableDiffusionControlNetInpaintCannyGenerator.app()
|
57 |
+
with gr.Tab("Depth"):
|
58 |
+
StableDiffusionControlInpaintNetDepthGenerator.app()
|
59 |
+
with gr.Tab("HED"):
|
60 |
+
StableDiffusionControlNetInpaintHedGenerator.app()
|
61 |
+
with gr.Tab("MLSD"):
|
62 |
+
StableDiffusionControlNetInpaintMlsdGenerator.app()
|
63 |
+
with gr.Tab("Pose"):
|
64 |
+
StableDiffusionControlNetInpaintPoseGenerator.app()
|
65 |
+
with gr.Tab("Scribble"):
|
66 |
+
StableDiffusionControlNetInpaintScribbleGenerator.app()
|
67 |
+
with gr.Tab("Seg"):
|
68 |
+
StableDiffusionControlNetInpaintSegGenerator.app()
|
69 |
+
with gr.Tab("Upscaler"):
|
70 |
+
CodeformerUpscalerGenerator.app()
|
71 |
+
|
72 |
+
app.queue(concurrency_count=2)
|
73 |
+
app.launch(debug=True, enable_queue=True)
|
74 |
+
|
75 |
+
|
76 |
+
if __name__ == "__main__":
|
77 |
+
diffusion_app()
|
diffusion_webui/diffusion_models/controlnet/__init__.py
CHANGED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_canny import StableDiffusionControlNetCannyGenerator
|
2 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_depth import StableDiffusionControlNetDepthGenerator
|
3 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_hed import StableDiffusionControlNetHEDGenerator
|
4 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_mlsd import StableDiffusionControlNetMLSDGenerator
|
5 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_normal import StableDiffusionControlNetNormalGenerator
|
6 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_pose import StableDiffusionControlNetPoseGenerator
|
7 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_scribble import StableDiffusionControlNetScribbleGenerator
|
8 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_seg import StableDiffusionControlNetSegGenerator
|
diffusion_webui/diffusion_models/controlnet/controlnet_inpaint/__init__.py
CHANGED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_canny import StableDiffusionControlNetInpaintCannyGenerator
|
2 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_depth import StableDiffusionControlInpaintNetDepthGenerator
|
3 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_hed import StableDiffusionControlNetInpaintHedGenerator
|
4 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_mlsd import StableDiffusionControlNetInpaintMlsdGenerator
|
5 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_pose import StableDiffusionControlNetInpaintPoseGenerator
|
6 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_scribble import StableDiffusionControlNetInpaintScribbleGenerator
|
7 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_seg import StableDiffusionControlNetInpaintSegGenerator
|
diffusion_webui/diffusion_models/controlnet/controlnet_mlsd.py
CHANGED
@@ -4,7 +4,7 @@ from controlnet_aux import MLSDdetector
|
|
4 |
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline
|
5 |
from PIL import Image
|
6 |
|
7 |
-
from diffusion_webui.utils.model_list import stable_model_list
|
8 |
from diffusion_webui.utils.scheduler_list import (
|
9 |
SCHEDULER_LIST,
|
10 |
get_scheduler_list,
|
@@ -45,7 +45,8 @@ class StableDiffusionControlNetMLSDGenerator:
|
|
45 |
def generate_image(
|
46 |
self,
|
47 |
image_path: str,
|
48 |
-
|
|
|
49 |
prompt: str,
|
50 |
negative_prompt: str,
|
51 |
num_images_per_prompt: int,
|
@@ -57,8 +58,8 @@ class StableDiffusionControlNetMLSDGenerator:
|
|
57 |
image = self.controlnet_mlsd(image_path=image_path)
|
58 |
|
59 |
pipe = self.load_model(
|
60 |
-
stable_model_path=
|
61 |
-
controlnet_model_path=
|
62 |
scheduler=scheduler,
|
63 |
)
|
64 |
|
@@ -124,6 +125,12 @@ class StableDiffusionControlNetMLSDGenerator:
|
|
124 |
|
125 |
with gr.Row():
|
126 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
controlnet_mlsd_scheduler = gr.Dropdown(
|
128 |
choices=SCHEDULER_LIST,
|
129 |
value=SCHEDULER_LIST[0],
|
|
|
4 |
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline
|
5 |
from PIL import Image
|
6 |
|
7 |
+
from diffusion_webui.utils.model_list import stable_model_list, controlnet_mlsd_model_list
|
8 |
from diffusion_webui.utils.scheduler_list import (
|
9 |
SCHEDULER_LIST,
|
10 |
get_scheduler_list,
|
|
|
45 |
def generate_image(
|
46 |
self,
|
47 |
image_path: str,
|
48 |
+
stable_model_path: str,
|
49 |
+
controlnet_model_path: str,
|
50 |
prompt: str,
|
51 |
negative_prompt: str,
|
52 |
num_images_per_prompt: int,
|
|
|
58 |
image = self.controlnet_mlsd(image_path=image_path)
|
59 |
|
60 |
pipe = self.load_model(
|
61 |
+
stable_model_path=stable_model_path,
|
62 |
+
controlnet_model_path=controlnet_model_path,
|
63 |
scheduler=scheduler,
|
64 |
)
|
65 |
|
|
|
125 |
|
126 |
with gr.Row():
|
127 |
with gr.Column():
|
128 |
+
controlnet_mlsd_controlnet_model_id = gr.Dropdown(
|
129 |
+
choices=controlnet_mlsd_model_list,
|
130 |
+
value=controlnet_mlsd_model_list[0],
|
131 |
+
label="ControlNet Model Id",
|
132 |
+
|
133 |
+
)
|
134 |
controlnet_mlsd_scheduler = gr.Dropdown(
|
135 |
choices=SCHEDULER_LIST,
|
136 |
value=SCHEDULER_LIST[0],
|
diffusion_webui/diffusion_models/controlnet/controlnet_normal.py
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
|
2 |
+
from diffusers.utils import load_image
|
3 |
+
from transformers import pipeline
|
4 |
+
from PIL import Image
|
5 |
+
import gradio as gr
|
6 |
+
import numpy as np
|
7 |
+
import torch
|
8 |
+
import cv2
|
9 |
+
|
10 |
+
|
11 |
+
from diffusion_webui.utils.model_list import (
|
12 |
+
controlnet_normal_model_list,
|
13 |
+
stable_model_list,
|
14 |
+
)
|
15 |
+
from diffusion_webui.utils.scheduler_list import (
|
16 |
+
SCHEDULER_LIST,
|
17 |
+
get_scheduler_list,
|
18 |
+
)
|
19 |
+
|
20 |
+
|
21 |
+
class StableDiffusionControlNetNormalGenerator:
|
22 |
+
def __init__(self):
|
23 |
+
self.pipe = None
|
24 |
+
|
25 |
+
def load_model(self, stable_model_path, controlnet_model_path, scheduler):
|
26 |
+
if self.pipe is None:
|
27 |
+
controlnet = ControlNetModel.from_pretrained(
|
28 |
+
controlnet_model_path, torch_dtype=torch.float16
|
29 |
+
)
|
30 |
+
self.pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
31 |
+
pretrained_model_name_or_path=stable_model_path,
|
32 |
+
controlnet=controlnet,
|
33 |
+
safety_checker=None,
|
34 |
+
torch_dtype=torch.float16,
|
35 |
+
)
|
36 |
+
|
37 |
+
self.pipe = get_scheduler_list(pipe=self.pipe, scheduler=scheduler)
|
38 |
+
self.pipe.to("cuda")
|
39 |
+
self.pipe.enable_xformers_memory_efficient_attention()
|
40 |
+
|
41 |
+
return self.pipe
|
42 |
+
|
43 |
+
def controlnet_normal(
|
44 |
+
self,
|
45 |
+
image_path: str,
|
46 |
+
):
|
47 |
+
image = load_image(image_path).convert("RGB")
|
48 |
+
depth_estimator = pipeline("depth-estimation", model ="Intel/dpt-hybrid-midas" )
|
49 |
+
image = depth_estimator(image)['predicted_depth'][0]
|
50 |
+
image = image.numpy()
|
51 |
+
image_depth = image.copy()
|
52 |
+
image_depth -= np.min(image_depth)
|
53 |
+
image_depth /= np.max(image_depth)
|
54 |
+
bg_threhold = 0.4
|
55 |
+
x = cv2.Sobel(image, cv2.CV_32F, 1, 0, ksize=3)
|
56 |
+
x[image_depth < bg_threhold] = 0
|
57 |
+
y = cv2.Sobel(image, cv2.CV_32F, 0, 1, ksize=3)
|
58 |
+
y[image_depth < bg_threhold] = 0
|
59 |
+
z = np.ones_like(x) * np.pi * 2.0
|
60 |
+
image = np.stack([x, y, z], axis=2)
|
61 |
+
image /= np.sum(image ** 2.0, axis=2, keepdims=True) ** 0.5
|
62 |
+
image = (image * 127.5 + 127.5).clip(0, 255).astype(np.uint8)
|
63 |
+
image = Image.fromarray(image)
|
64 |
+
return image
|
65 |
+
|
66 |
+
def generate_image(
|
67 |
+
self,
|
68 |
+
image_path: str,
|
69 |
+
stable_model_path: str,
|
70 |
+
controlnet_model_path: str,
|
71 |
+
prompt: str,
|
72 |
+
negative_prompt: str,
|
73 |
+
num_images_per_prompt: int,
|
74 |
+
guidance_scale: int,
|
75 |
+
num_inference_step: int,
|
76 |
+
scheduler: str,
|
77 |
+
seed_generator: int,
|
78 |
+
):
|
79 |
+
pipe = self.load_model(stable_model_path, controlnet_model_path, scheduler)
|
80 |
+
image = self.controlnet_normal(image_path)
|
81 |
+
|
82 |
+
if seed_generator == 0:
|
83 |
+
random_seed = torch.randint(0, 1000000, (1,))
|
84 |
+
generator = torch.manual_seed(random_seed)
|
85 |
+
else:
|
86 |
+
generator = torch.manual_seed(seed_generator)
|
87 |
+
|
88 |
+
output = pipe(
|
89 |
+
prompt=prompt,
|
90 |
+
image=image,
|
91 |
+
negative_prompt=negative_prompt,
|
92 |
+
num_images_per_prompt=num_images_per_prompt,
|
93 |
+
num_inference_steps=num_inference_step,
|
94 |
+
guidance_scale=guidance_scale,
|
95 |
+
generator=generator,
|
96 |
+
).images
|
97 |
+
|
98 |
+
return output
|
99 |
+
|
100 |
+
def app():
|
101 |
+
with gr.Blocks():
|
102 |
+
with gr.Row():
|
103 |
+
with gr.Column():
|
104 |
+
controlnet_normal_image_file = gr.Image(
|
105 |
+
type="filepath", label="Image"
|
106 |
+
)
|
107 |
+
|
108 |
+
controlnet_normal_prompt = gr.Textbox(
|
109 |
+
lines=1,
|
110 |
+
placeholder="Prompt",
|
111 |
+
show_label=False,
|
112 |
+
)
|
113 |
+
|
114 |
+
controlnet_normal_negative_prompt = gr.Textbox(
|
115 |
+
lines=1,
|
116 |
+
placeholder="Negative Prompt",
|
117 |
+
show_label=False,
|
118 |
+
)
|
119 |
+
with gr.Row():
|
120 |
+
with gr.Column():
|
121 |
+
controlnet_normal_stable_model_id = gr.Dropdown(
|
122 |
+
choices=stable_model_list,
|
123 |
+
value=stable_model_list[0],
|
124 |
+
label="Stable Model Id",
|
125 |
+
)
|
126 |
+
|
127 |
+
controlnet_normal_guidance_scale = gr.Slider(
|
128 |
+
minimum=0.1,
|
129 |
+
maximum=15,
|
130 |
+
step=0.1,
|
131 |
+
value=7.5,
|
132 |
+
label="Guidance Scale",
|
133 |
+
)
|
134 |
+
controlnet_normal_num_inference_step = gr.Slider(
|
135 |
+
minimum=1,
|
136 |
+
maximum=100,
|
137 |
+
step=1,
|
138 |
+
value=50,
|
139 |
+
label="Num Inference Step",
|
140 |
+
)
|
141 |
+
controlnet_normal_num_images_per_prompt = gr.Slider(
|
142 |
+
minimum=1,
|
143 |
+
maximum=10,
|
144 |
+
step=1,
|
145 |
+
value=1,
|
146 |
+
label="Number Of Images",
|
147 |
+
)
|
148 |
+
with gr.Row():
|
149 |
+
with gr.Column():
|
150 |
+
controlnet_normal_model_id = gr.Dropdown(
|
151 |
+
choices=controlnet_normal_model_list,
|
152 |
+
value=controlnet_normal_model_list[0],
|
153 |
+
label="ControlNet Model Id",
|
154 |
+
)
|
155 |
+
|
156 |
+
controlnet_normal_scheduler = gr.Dropdown(
|
157 |
+
choices=SCHEDULER_LIST,
|
158 |
+
value=SCHEDULER_LIST[0],
|
159 |
+
label="Scheduler",
|
160 |
+
)
|
161 |
+
|
162 |
+
controlnet_normal_seed_generator = gr.Number(
|
163 |
+
value=0,
|
164 |
+
label="Seed Generator",
|
165 |
+
)
|
166 |
+
controlnet_normal_predict = gr.Button(value="Generator")
|
167 |
+
|
168 |
+
with gr.Column():
|
169 |
+
output_image = gr.Gallery(
|
170 |
+
label="Generated images",
|
171 |
+
show_label=False,
|
172 |
+
elem_id="gallery",
|
173 |
+
).style(grid=(1, 2))
|
174 |
+
|
175 |
+
controlnet_normal_predict.click(
|
176 |
+
fn=StableDiffusionControlNetCannyGenerator().generate_image,
|
177 |
+
inputs=[
|
178 |
+
controlnet_normal_image_file,
|
179 |
+
controlnet_normal_stable_model_id,
|
180 |
+
controlnet_normal_model_id,
|
181 |
+
controlnet_normal_prompt,
|
182 |
+
controlnet_normal_negative_prompt,
|
183 |
+
controlnet_normal_num_images_per_prompt,
|
184 |
+
controlnet_normal_guidance_scale,
|
185 |
+
controlnet_normal_num_inference_step,
|
186 |
+
controlnet_normal_scheduler,
|
187 |
+
controlnet_normal_seed_generator,
|
188 |
+
],
|
189 |
+
outputs=[output_image],
|
190 |
+
)
|
diffusion_webui/diffusion_models/stable_diffusion/__init__.py
CHANGED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from diffusion_webui.diffusion_models.stable_diffusion.text2img_app import StableDiffusionText2ImageGenerator
|
2 |
+
from diffusion_webui.diffusion_models.stable_diffusion.img2img_app import StableDiffusionImage2ImageGenerator
|
3 |
+
from diffusion_webui.diffusion_models.stable_diffusion.inpaint_app import StableDiffusionInpaintGenerator
|
diffusion_webui/helpers.py
CHANGED
@@ -1,54 +1,25 @@
|
|
1 |
-
from diffusion_webui.diffusion_models.
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
StableDiffusionControlNetDepthGenerator,
|
6 |
-
)
|
7 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_hed import (
|
8 |
-
StableDiffusionControlNetHEDGenerator,
|
9 |
)
|
10 |
-
|
|
|
11 |
StableDiffusionControlNetInpaintCannyGenerator,
|
12 |
-
)
|
13 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_depth import (
|
14 |
StableDiffusionControlInpaintNetDepthGenerator,
|
15 |
-
)
|
16 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_hed import (
|
17 |
StableDiffusionControlNetInpaintHedGenerator,
|
18 |
-
)
|
19 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_mlsd import (
|
20 |
StableDiffusionControlNetInpaintMlsdGenerator,
|
21 |
-
)
|
22 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_pose import (
|
23 |
StableDiffusionControlNetInpaintPoseGenerator,
|
24 |
-
)
|
25 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_scribble import (
|
26 |
StableDiffusionControlNetInpaintScribbleGenerator,
|
27 |
-
)
|
28 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint.controlnet_inpaint_seg import (
|
29 |
StableDiffusionControlNetInpaintSegGenerator,
|
30 |
-
)
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
StableDiffusionControlNetMLSDGenerator,
|
33 |
-
)
|
34 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_pose import (
|
35 |
StableDiffusionControlNetPoseGenerator,
|
36 |
-
)
|
37 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_scribble import (
|
38 |
StableDiffusionControlNetScribbleGenerator,
|
39 |
-
)
|
40 |
-
from diffusion_webui.diffusion_models.controlnet.controlnet_seg import (
|
41 |
StableDiffusionControlNetSegGenerator,
|
42 |
)
|
43 |
-
from diffusion_webui.diffusion_models.stable_diffusion.img2img_app import (
|
44 |
-
StableDiffusionImage2ImageGenerator,
|
45 |
-
)
|
46 |
-
from diffusion_webui.diffusion_models.stable_diffusion.inpaint_app import (
|
47 |
-
StableDiffusionInpaintGenerator,
|
48 |
-
)
|
49 |
-
from diffusion_webui.diffusion_models.stable_diffusion.text2img_app import (
|
50 |
-
StableDiffusionText2ImageGenerator,
|
51 |
-
)
|
52 |
-
from diffusion_webui.upscaler_models.codeformer_upscaler import (
|
53 |
-
CodeformerUpscalerGenerator,
|
54 |
-
)
|
|
|
1 |
+
from diffusion_webui.diffusion_models.stable_diffusion import (
|
2 |
+
StableDiffusionText2ImageGenerator,
|
3 |
+
StableDiffusionImage2ImageGenerator,
|
4 |
+
StableDiffusionInpaintGenerator,
|
|
|
|
|
|
|
|
|
5 |
)
|
6 |
+
|
7 |
+
from diffusion_webui.diffusion_models.controlnet.controlnet_inpaint import (
|
8 |
StableDiffusionControlNetInpaintCannyGenerator,
|
|
|
|
|
9 |
StableDiffusionControlInpaintNetDepthGenerator,
|
|
|
|
|
10 |
StableDiffusionControlNetInpaintHedGenerator,
|
|
|
|
|
11 |
StableDiffusionControlNetInpaintMlsdGenerator,
|
|
|
|
|
12 |
StableDiffusionControlNetInpaintPoseGenerator,
|
|
|
|
|
13 |
StableDiffusionControlNetInpaintScribbleGenerator,
|
|
|
|
|
14 |
StableDiffusionControlNetInpaintSegGenerator,
|
15 |
+
)
|
16 |
+
|
17 |
+
from diffusion_webui.diffusion_models.controlnet import (
|
18 |
+
StableDiffusionControlNetCannyGenerator,
|
19 |
+
StableDiffusionControlNetDepthGenerator,
|
20 |
+
StableDiffusionControlNetHEDGenerator,
|
21 |
StableDiffusionControlNetMLSDGenerator,
|
|
|
|
|
22 |
StableDiffusionControlNetPoseGenerator,
|
|
|
|
|
23 |
StableDiffusionControlNetScribbleGenerator,
|
|
|
|
|
24 |
StableDiffusionControlNetSegGenerator,
|
25 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diffusion_webui/utils/model_list.py
CHANGED
@@ -6,22 +6,22 @@ stable_model_list = [
|
|
6 |
"dreamlike-art/dreamlike-diffusion-1.0",
|
7 |
"gsdf/Counterfeit-V2.5",
|
8 |
"dreamlike-art/dreamlike-photoreal-2.0"
|
9 |
-
|
10 |
-
|
11 |
]
|
12 |
|
13 |
controlnet_canny_model_list = [
|
14 |
"lllyasviel/sd-controlnet-canny",
|
15 |
"lllyasviel/control_v11p_sd15_canny",
|
16 |
"thibaud/controlnet-sd21-canny-diffusers",
|
|
|
17 |
]
|
18 |
|
19 |
controlnet_depth_model_list = [
|
20 |
"lllyasviel/sd-controlnet-depth",
|
21 |
-
"lllyasviel/
|
22 |
"thibaud/controlnet-sd21-depth-diffusers",
|
23 |
]
|
24 |
|
|
|
25 |
controlnet_pose_model_list = [
|
26 |
"lllyasviel/sd-controlnet-openpose",
|
27 |
"lllyasviel/control_v11p_sd15_openpose",
|
@@ -30,12 +30,12 @@ controlnet_pose_model_list = [
|
|
30 |
|
31 |
controlnet_hed_model_list = [
|
32 |
"lllyasviel/sd-controlnet-hed",
|
33 |
-
"lllyasviel/control_v11p_sd15_scribble",
|
34 |
"thibaud/controlnet-sd21-hed-diffusers",
|
35 |
]
|
36 |
|
37 |
controlnet_scribble_model_list = [
|
38 |
"lllyasviel/sd-controlnet-scribble",
|
|
|
39 |
"thibaud/controlnet-sd21-scribble-diffusers",
|
40 |
]
|
41 |
stable_inpiant_model_list = [
|
@@ -48,6 +48,11 @@ controlnet_mlsd_model_list = [
|
|
48 |
"lllyasviel/control_v11p_sd15_mlsd",
|
49 |
]
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
controlnet_seg_model_list = [
|
52 |
"lllyasviel/sd-controlnet-seg",
|
53 |
"lllyasviel/control_v11p_sd15_seg",
|
|
|
6 |
"dreamlike-art/dreamlike-diffusion-1.0",
|
7 |
"gsdf/Counterfeit-V2.5",
|
8 |
"dreamlike-art/dreamlike-photoreal-2.0"
|
|
|
|
|
9 |
]
|
10 |
|
11 |
controlnet_canny_model_list = [
|
12 |
"lllyasviel/sd-controlnet-canny",
|
13 |
"lllyasviel/control_v11p_sd15_canny",
|
14 |
"thibaud/controlnet-sd21-canny-diffusers",
|
15 |
+
|
16 |
]
|
17 |
|
18 |
controlnet_depth_model_list = [
|
19 |
"lllyasviel/sd-controlnet-depth",
|
20 |
+
"lllyasviel/control_v11f1p_sd15_depth",
|
21 |
"thibaud/controlnet-sd21-depth-diffusers",
|
22 |
]
|
23 |
|
24 |
+
|
25 |
controlnet_pose_model_list = [
|
26 |
"lllyasviel/sd-controlnet-openpose",
|
27 |
"lllyasviel/control_v11p_sd15_openpose",
|
|
|
30 |
|
31 |
controlnet_hed_model_list = [
|
32 |
"lllyasviel/sd-controlnet-hed",
|
|
|
33 |
"thibaud/controlnet-sd21-hed-diffusers",
|
34 |
]
|
35 |
|
36 |
controlnet_scribble_model_list = [
|
37 |
"lllyasviel/sd-controlnet-scribble",
|
38 |
+
"lllyasviel/control_v11p_sd15_scribble",
|
39 |
"thibaud/controlnet-sd21-scribble-diffusers",
|
40 |
]
|
41 |
stable_inpiant_model_list = [
|
|
|
48 |
"lllyasviel/control_v11p_sd15_mlsd",
|
49 |
]
|
50 |
|
51 |
+
controlnet_normal_model_list = [
|
52 |
+
"lllyasviel/sd-controlnet-normal",
|
53 |
+
"lllyasviel/control_v11p_sd15_normalbae",
|
54 |
+
]
|
55 |
+
|
56 |
controlnet_seg_model_list = [
|
57 |
"lllyasviel/sd-controlnet-seg",
|
58 |
"lllyasviel/control_v11p_sd15_seg",
|