Skip to content

Commit 80177ae

Browse files
authored
Merge pull request #8 from R3gm/dev2
version 0.5.0
2 parents 585eedc + a5fd310 commit 80177ae

File tree

11 files changed

+462
-229
lines changed

11 files changed

+462
-229
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The goal of this project is to make Stable Diffusion more accessible, simple and
66

77
**Installation:**
88
```
9-
pip install stablepy==0.4.1
9+
pip install stablepy==0.5.0
1010
```
1111

1212
**Usage:**
@@ -80,6 +80,16 @@ images[1]
8080
```
8181
**📖 News:**
8282

83+
🔥 Version 0.5.0: New Update Details
84+
85+
- Fix LoRA SDXL compatibility.
86+
- Latent upscaler and variants.
87+
- Perturbed Attention Guidance (PAG) enhances image generation quality without the need for training.
88+
- Multiple images for one FaceID adapter.
89+
- ControlNet for SDXL: MLSD, Segmentation, Normalbae.
90+
- ControlNet "lineart_anime" task accessible and able to load a model different from the "lineart" task.
91+
- ControlNet Tile and Recolor for SD1.5 and SDXL ("tile" replaces the previous task called "sdxl_tile_realistic").
92+
8393
🔥 Version 0.4.0: New Update Details
8494

8595
- IP Adapter with the variants FaceID and Instant-Style

poetry.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "stablepy"
3-
version = "0.4.1"
3+
version = "0.5.0"
44
description = "A tool for easy use of stable diffusion"
55
authors = ["Roger Condori(R3gm) <rocondoriflores@gmail.com>"]
66
readme = "README.md"
@@ -11,7 +11,7 @@ torch = {version = "*", source = "pytorch-gpu-src"}
1111
torchvision = {version = "*", source = "pytorch-gpu-src"}
1212
torchaudio = {version = "*", source = "pytorch-gpu-src"}
1313
omegaconf = "2.3.0"
14-
diffusers = "0.29.0"
14+
diffusers = "0.30.2"
1515
compel = "2.0.2"
1616
invisible-watermark = "^0.2.0"
1717
transformers = "^4.41.2"
@@ -28,6 +28,7 @@ peft = "^0.11.1"
2828
torchsde = "^0.2.6"
2929
onnxruntime = "^1.18.0"
3030
insightface = "^0.7.3"
31+
opencv-contrib-python = "^4.8.0.76"
3132

3233
[[tool.poetry.source]]
3334
name = "pytorch-gpu-src"

stablepy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .diffusers_vanilla import utils
55
from .upscalers.esrgan import UpscalerESRGAN, UpscalerLanczos, UpscalerNearest
66
from .logging.logging_setup import logger
7+
from .diffusers_vanilla.high_resolution import LATENT_UPSCALERS
78
from .diffusers_vanilla.constants import (
89
CONTROLNET_MODEL_IDS,
910
VALID_TASKS,

stablepy/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.1"
1+
__version__ = "0.5.0"

stablepy/diffusers_vanilla/constants.py

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,68 @@
1818
EDMEulerScheduler,
1919
TCDScheduler,
2020
)
21+
from diffusers import (
22+
StableDiffusionControlNetPipeline,
23+
StableDiffusionControlNetInpaintPipeline,
24+
StableDiffusionPipeline,
25+
StableDiffusionXLInpaintPipeline,
26+
StableDiffusionXLAdapterPipeline,
27+
StableDiffusionXLPipeline,
28+
StableDiffusionXLControlNetPipeline,
29+
StableDiffusionPAGPipeline,
30+
# StableDiffusionControlNetPAGInpaintPipeline,
31+
StableDiffusionControlNetPAGPipeline,
32+
# StableDiffusionControlNetImg2ImgPAGPipeline,
33+
StableDiffusionXLPAGPipeline,
34+
StableDiffusionXLPAGInpaintPipeline,
35+
StableDiffusionXLControlNetPAGPipeline,
36+
# StableDiffusionXLAdapterPAGPipeline,
37+
# StableDiffusionXLControlNetImg2ImgPAGPipeline,
38+
)
39+
40+
CLASS_DIFFUSERS_TASK = {
41+
"StableDiffusionPipeline": {
42+
"base": StableDiffusionPipeline,
43+
"inpaint": StableDiffusionControlNetInpaintPipeline,
44+
"controlnet": StableDiffusionControlNetPipeline,
45+
# "controlnet_img2img": StableDiffusionControlNetImg2ImgPipeline,
46+
},
47+
"StableDiffusionXLPipeline": {
48+
"base": StableDiffusionXLPipeline,
49+
"inpaint": StableDiffusionXLInpaintPipeline,
50+
"controlnet": StableDiffusionXLControlNetPipeline,
51+
"adapter": StableDiffusionXLAdapterPipeline,
52+
# "controlnet_img2img": StableDiffusionXLControlNetImg2ImgPipeline,
53+
},
54+
}
55+
56+
CLASS_PAG_DIFFUSERS_TASK = {
57+
"StableDiffusionPipeline": {
58+
"base": StableDiffusionPAGPipeline,
59+
"inpaint": StableDiffusionControlNetInpaintPipeline,
60+
"controlnet": StableDiffusionControlNetPAGPipeline,
61+
# "controlnet_img2img": StableDiffusionControlNetImg2ImgPAGPipeline,
62+
},
63+
"StableDiffusionXLPipeline": {
64+
"base": StableDiffusionXLPAGPipeline,
65+
"inpaint": StableDiffusionXLPAGInpaintPipeline,
66+
"controlnet": StableDiffusionXLControlNetPAGPipeline,
67+
# "adapter": StableDiffusionXLAdapterPAGPipeline,
68+
# "controlnet_img2img": StableDiffusionXLControlNetImg2ImgPAGPipeline,
69+
},
70+
}
2171

2272
CONTROLNET_MODEL_IDS = {
2373
"openpose": ["lllyasviel/control_v11p_sd15_openpose", "r3gm/controlnet-openpose-sdxl-1.0-fp16"],
2474
"canny": ["lllyasviel/control_v11p_sd15_canny", "r3gm/controlnet-canny-scribble-integrated-sdxl-v2-fp16"],
25-
"mlsd": "lllyasviel/control_v11p_sd15_mlsd",
75+
"mlsd": ["lllyasviel/control_v11p_sd15_mlsd", "r3gm/controlnet-union-sdxl-1.0-fp16"],
2676
"scribble": ["lllyasviel/control_v11p_sd15_scribble", "r3gm/controlnet-canny-scribble-integrated-sdxl-v2-fp16"],
27-
"softedge": ["lllyasviel/control_v11p_sd15_softedge", "r3gm/controlnet-canny-scribble-integrated-sdxl-v2-fp16"],
28-
"segmentation": "lllyasviel/control_v11p_sd15_seg",
29-
"depth": ["lllyasviel/control_v11f1p_sd15_depth", "diffusers/controlnet-depth-sdxl-1.0-mid"],
30-
"normalbae": "lllyasviel/control_v11p_sd15_normalbae",
31-
"lineart": ["lllyasviel/control_v11p_sd15_lineart", "r3gm/controlnet-lineart-anime-sdxl-fp16"],
32-
"lineart_anime": "lllyasviel/control_v11p_sd15s2_lineart_anime",
77+
"softedge": ["lllyasviel/control_v11p_sd15_softedge", "r3gm/controlnet-union-sdxl-1.0-fp16"],
78+
"segmentation": ["lllyasviel/control_v11p_sd15_seg", "r3gm/controlnet-union-sdxl-1.0-fp16"],
79+
"depth": ["lllyasviel/control_v11f1p_sd15_depth", "r3gm/controlnet-union-sdxl-1.0-fp16"],
80+
"normalbae": ["lllyasviel/control_v11p_sd15_normalbae", "r3gm/controlnet-union-sdxl-1.0-fp16"],
81+
"lineart": ["lllyasviel/control_v11p_sd15_lineart", "r3gm/controlnet-union-sdxl-1.0-fp16"],
82+
"lineart_anime": ["lllyasviel/control_v11p_sd15s2_lineart_anime", "r3gm/controlnet-lineart-anime-sdxl-fp16"],
3383
"shuffle": "lllyasviel/control_v11e_sd15_shuffle",
3484
"ip2p": "lllyasviel/control_v11e_sd15_ip2p",
3585
"inpaint": "lllyasviel/control_v11p_sd15_inpaint",
@@ -41,7 +91,8 @@
4191
"sdxl_openpose_t2i": "TencentARC/t2i-adapter-openpose-sdxl-1.0",
4292
"img2img": "Nothinghere",
4393
"pattern": ["monster-labs/control_v1p_sd15_qrcode_monster", "r3gm/control_v1p_sdxl_qrcode_monster_fp16"],
44-
"sdxl_tile_realistic": "Yakonrus/SDXL_Controlnet_Tile_Realistic_v2",
94+
"tile": ["lllyasviel/control_v11f1e_sd15_tile", "r3gm/controlnet-tile-sdxl-1.0-fp16"], # "sdxl_tile_realistic": "Yakonrus/SDXL_Controlnet_Tile_Realistic_v2",
95+
"recolor": ["latentcat/control_v1p_sd15_brightness", "r3gm/controlnet-recolor-sdxl-fp16"],
4596
# "sdxl_depth-zoe_t2i": "TencentARC/t2i-adapter-depth-zoe-sdxl-1.0",
4697
# "sdxl_recolor_t2i": "TencentARC/t2i-adapter-recolor-sdxl-1.0",
4798
}
@@ -89,16 +140,17 @@
89140
OLD_PROMPT_WEIGHT_OPTIONS = ALL_PROMPT_WEIGHT_OPTIONS[0:2]
90141

91142
SCHEDULER_CONFIG_MAP = {
92-
"DPM++ 2M": (DPMSolverMultistepScheduler, {"use_karras_sigmas": False}),
93-
"DPM++ 2M Karras": (DPMSolverMultistepScheduler, {"use_karras_sigmas": True}),
143+
"DPM++ 2M": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "use_karras_sigmas": False}),
144+
"DPM++ 2M Karras": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "use_karras_sigmas": True}),
94145
"DPM++ 2M SDE": (DPMSolverMultistepScheduler, {"use_karras_sigmas": False, "algorithm_type": "sde-dpmsolver++"}),
95146
"DPM++ 2M SDE Karras": (DPMSolverMultistepScheduler, {"use_karras_sigmas": True, "algorithm_type": "sde-dpmsolver++"}),
96-
"DPM++ 2S": (DPMSolverSinglestepScheduler, {"use_karras_sigmas": False}),
97-
"DPM++ 2S Karras": (DPMSolverSinglestepScheduler, {"use_karras_sigmas": True}),
98-
"DPM++ 1S": (DPMSolverMultistepScheduler, {"solver_order": 1}),
99-
"DPM++ 1S Karras": (DPMSolverMultistepScheduler, {"solver_order": 1, "use_karras_sigmas": True}),
100-
"DPM++ 3M": (DPMSolverMultistepScheduler, {"solver_order": 3}),
101-
"DPM++ 3M Karras": (DPMSolverMultistepScheduler, {"solver_order": 3, "use_karras_sigmas": True}),
147+
"DPM++ 2S": (DPMSolverSinglestepScheduler, {"algorithm_type": "dpmsolver++", "use_karras_sigmas": False}),
148+
"DPM++ 2S Karras": (DPMSolverSinglestepScheduler, {"algorithm_type": "dpmsolver++", "use_karras_sigmas": True}),
149+
"DPM++ 1S": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "solver_order": 1}),
150+
"DPM++ 1S Karras": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "solver_order": 1, "use_karras_sigmas": True}),
151+
"DPM++ 3M": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "solver_order": 3}),
152+
"DPM++ 3M Karras": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "solver_order": 3, "use_karras_sigmas": True}),
153+
"DPM 3M": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver", "final_sigmas_type": "sigma_min", "solver_order": 3}),
102154
"DPM++ SDE": (DPMSolverSDEScheduler, {"use_karras_sigmas": False}),
103155
"DPM++ SDE Karras": (DPMSolverSDEScheduler, {"use_karras_sigmas": True}),
104156
"DPM2": (KDPM2DiscreteScheduler, {}),
@@ -125,8 +177,8 @@
125177
"DPM++ 2M EDM Karras": (EDMDPMSolverMultistepScheduler, {"use_karras_sigmas": True, "solver_order": 2, "solver_type": "midpoint", "final_sigmas_type": "zero", "algorithm_type": "dpmsolver++"}),
126178
"DDPM": (DDPMScheduler, {}),
127179

128-
"DPM++ 2M Lu": (DPMSolverMultistepScheduler, {"use_lu_lambdas": True}),
129-
"DPM++ 2M Ef": (DPMSolverMultistepScheduler, {"euler_at_final": True}),
180+
"DPM++ 2M Lu": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "use_lu_lambdas": True}),
181+
"DPM++ 2M Ef": (DPMSolverMultistepScheduler, {"algorithm_type": "dpmsolver++", "euler_at_final": True}),
130182
"DPM++ 2M SDE Lu": (DPMSolverMultistepScheduler, {"use_lu_lambdas": True, "algorithm_type": "sde-dpmsolver++"}),
131183
"DPM++ 2M SDE Ef": (DPMSolverMultistepScheduler, {"algorithm_type": "sde-dpmsolver++", "euler_at_final": True}),
132184

@@ -153,9 +205,9 @@
153205
"base_light_v2": ["h94/IP-Adapter", "models", "ip-adapter_sd15_light_v11.bin", "H"],
154206
"faceid_plus": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-plus_sd15.bin", "H"],
155207
"faceid_plus_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-plusv2_sd15.bin", "H"],
156-
"faceid": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid_sd15.bin", None],
157-
"faceid_portrait_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait-v11_sd15.bin", None], # last portrait
158-
"faceid_portrait": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sd15.bin", None],
208+
"faceid": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid_sd15.bin", "H"], # None
209+
"faceid_portrait_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait-v11_sd15.bin", "H"], # None
210+
"faceid_portrait": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sd15.bin", "H"], # None
159211
"composition_plus": ["ostris/ip-composition-adapter", "", "ip_plus_composition_sd15.safetensors", "H"]
160212
},
161213
"StableDiffusionXLPipeline": {
@@ -165,9 +217,9 @@
165217
"base_vit_G": ["h94/IP-Adapter", "sdxl_models", "ip-adapter_sdxl.safetensors", "G"],
166218
"base": ["h94/IP-Adapter", "sdxl_models", "ip-adapter_sdxl_vit-h.safetensors", "H"],
167219
"faceid_plus_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-plusv2_sdxl.bin", "H"],
168-
"faceid": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid_sdxl.bin", None],
169-
"faceid_portrait": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sdxl.bin", None],
170-
"faceid_portrait_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sdxl_unnorm.bin", None],
220+
"faceid": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid_sdxl.bin", "H"], # None
221+
"faceid_portrait": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sdxl.bin", "H"], # None
222+
"faceid_portrait_v2": ["h94/IP-Adapter-FaceID", "", "ip-adapter-faceid-portrait_sdxl_unnorm.bin", "H"], # None
171223
"composition_plus": ["ostris/ip-composition-adapter", "", "ip_plus_composition_sdxl.safetensors", "H"]
172224
}
173225
} # no suffix lora

stablepy/diffusers_vanilla/extra_model_loaders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def custom_task_model_loader(
6464

6565
elif model_category in ["hires", "detailfix_img2img"]:
6666
# Pipe hires detailfix_pipe img2img
67-
if task_name != "txt2img":
67+
if task_name != "txt2img" or hasattr(pipe, "set_pag_applied_layers"):
6868
if not hasattr(pipe, "text_encoder_2"):
6969
hires_pipe = StableDiffusionPipeline(
7070
vae=pipe.vae,
@@ -91,9 +91,9 @@ def custom_task_model_loader(
9191
image_encoder=pipe.image_encoder,
9292
)
9393

94-
hires_pipe = AutoPipelineForImage2Image.from_pipe(hires_pipe)
94+
hires_pipe = AutoPipelineForImage2Image.from_pipe(hires_pipe, enable_pag=False)
9595
else:
96-
hires_pipe = AutoPipelineForImage2Image.from_pipe(pipe)
96+
hires_pipe = AutoPipelineForImage2Image.from_pipe(pipe, enable_pag=False)
9797

9898
if hasattr(hires_pipe, "text_encoder_2"):
9999
hires_pipe.enable_vae_slicing()

0 commit comments

Comments
 (0)