Spaces:
Runtime error
Runtime error
Update diffusion_webui/diffusion_models/controlnet_pipeline.py
Browse files
diffusion_webui/diffusion_models/controlnet_pipeline.py
CHANGED
|
@@ -18,12 +18,38 @@ from diffusion_webui.utils.scheduler_list import (
|
|
| 18 |
)
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
class StableDiffusionControlNetGenerator(ControlnetPipeline):
|
| 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 |
)
|
|
@@ -33,13 +59,16 @@ class StableDiffusionControlNetGenerator(ControlnetPipeline):
|
|
| 33 |
safety_checker=None,
|
| 34 |
torch_dtype=torch.float16,
|
| 35 |
)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
return self.pipe
|
| 42 |
|
|
|
|
| 43 |
def controlnet_preprocces(
|
| 44 |
self,
|
| 45 |
read_image: str,
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
|
| 21 |
+
stable_model_list = [
|
| 22 |
+
"runwayml/stable-diffusion-v1-5",
|
| 23 |
+
"dreamlike-art/dreamlike-diffusion-1.0",
|
| 24 |
+
"kadirnar/maturemalemix_v0",
|
| 25 |
+
"kadirnar/DreamShaper_v6"
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
stable_inpiant_model_list = [
|
| 29 |
+
"stabilityai/stable-diffusion-2-inpainting",
|
| 30 |
+
"runwayml/stable-diffusion-inpainting",
|
| 31 |
+
"saik0s/realistic_vision_inpainting",
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
controlnet_model_list = [
|
| 35 |
+
"lllyasviel/control_v11p_sd15_canny",
|
| 36 |
+
"lllyasviel/control_v11f1p_sd15_depth",
|
| 37 |
+
"lllyasviel/control_v11p_sd15_openpose",
|
| 38 |
+
"lllyasviel/control_v11p_sd15_scribble",
|
| 39 |
+
"lllyasviel/control_v11p_sd15_mlsd",
|
| 40 |
+
"lllyasviel/control_v11e_sd15_shuffle",
|
| 41 |
+
"lllyasviel/control_v11e_sd15_ip2p",
|
| 42 |
+
"lllyasviel/control_v11p_sd15_lineart",
|
| 43 |
+
"lllyasviel/control_v11p_sd15s2_lineart_anime",
|
| 44 |
+
"lllyasviel/control_v11p_sd15_softedge",
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
class StableDiffusionControlNetGenerator(ControlnetPipeline):
|
| 48 |
def __init__(self):
|
| 49 |
self.pipe = None
|
| 50 |
+
|
| 51 |
def load_model(self, stable_model_path, controlnet_model_path, scheduler):
|
| 52 |
+
if self.pipe is None or self.pipe.model_name != stable_model_path or self.pipe.scheduler_name != scheduler:
|
| 53 |
controlnet = ControlNetModel.from_pretrained(
|
| 54 |
controlnet_model_path, torch_dtype=torch.float16
|
| 55 |
)
|
|
|
|
| 59 |
safety_checker=None,
|
| 60 |
torch_dtype=torch.float16,
|
| 61 |
)
|
| 62 |
+
self.pipe.model_name = stable_model_path
|
| 63 |
+
|
| 64 |
+
self.pipe = get_scheduler(pipe=self.pipe, scheduler=scheduler)
|
| 65 |
+
self.pipe.scheduler_name = scheduler
|
| 66 |
+
self.pipe.to("cuda")
|
| 67 |
+
self.pipe.enable_xformers_memory_efficient_attention()
|
| 68 |
+
|
| 69 |
return self.pipe
|
| 70 |
|
| 71 |
+
|
| 72 |
def controlnet_preprocces(
|
| 73 |
self,
|
| 74 |
read_image: str,
|