Skip to content

Commit b863bdd

Browse files
authored
Modular Diffusers Guiders (#11311)
* cfg; slg; pag; sdxl without controlnet * support sdxl controlnet * support controlnet union * update * update * cfg zero* * use unwrap_module for torch compiled modules * remove guider kwargs * remove commented code * remove old guider * fix slg bug * remove debug print * autoguidance * smoothed energy guidance * add note about seg * tangential cfg * cfg plus plus * support cfgpp in ddim * apply review suggestions * refactor * rename enable/disable * remove cfg++ for now * rename do_classifier_free_guidance->prepare_unconditional_embeds * remove unused
1 parent d143851 commit b863bdd

19 files changed

+2458
-1075
lines changed

src/diffusers/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
_import_structure = {
3535
"configuration_utils": ["ConfigMixin"],
36+
"guiders": [],
3637
"hooks": [],
3738
"loaders": ["FromOriginalModelMixin"],
3839
"models": [],
@@ -129,12 +130,26 @@
129130
_import_structure["utils.dummy_pt_objects"] = [name for name in dir(dummy_pt_objects) if not name.startswith("_")]
130131

131132
else:
133+
_import_structure["guiders"].extend(
134+
[
135+
"AdaptiveProjectedGuidance",
136+
"AutoGuidance",
137+
"ClassifierFreeGuidance",
138+
"ClassifierFreeZeroStarGuidance",
139+
"SkipLayerGuidance",
140+
"SmoothedEnergyGuidance",
141+
"TangentialClassifierFreeGuidance",
142+
]
143+
)
132144
_import_structure["hooks"].extend(
133145
[
134146
"FasterCacheConfig",
135147
"HookRegistry",
136148
"PyramidAttentionBroadcastConfig",
149+
"LayerSkipConfig",
150+
"SmoothedEnergyGuidanceConfig",
137151
"apply_faster_cache",
152+
"apply_layer_skip",
138153
"apply_pyramid_attention_broadcast",
139154
]
140155
)
@@ -711,10 +726,22 @@
711726
except OptionalDependencyNotAvailable:
712727
from .utils.dummy_pt_objects import * # noqa F403
713728
else:
729+
from .guiders import (
730+
AdaptiveProjectedGuidance,
731+
AutoGuidance,
732+
ClassifierFreeGuidance,
733+
ClassifierFreeZeroStarGuidance,
734+
SkipLayerGuidance,
735+
SmoothedEnergyGuidance,
736+
TangentialClassifierFreeGuidance,
737+
)
714738
from .hooks import (
715739
FasterCacheConfig,
716740
HookRegistry,
741+
LayerSkipConfig,
717742
PyramidAttentionBroadcastConfig,
743+
SmoothedEnergyGuidanceConfig,
744+
apply_layer_skip,
718745
apply_faster_cache,
719746
apply_pyramid_attention_broadcast,
720747
)

0 commit comments

Comments
 (0)