mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
cleanup modular init
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+8
-4
@@ -14,7 +14,12 @@ modular_map= {
|
||||
|
||||
|
||||
def is_compatible(diffusion_pipeline: diffusers.DiffusionPipeline) -> bool:
|
||||
return diffusion_pipeline.__class__.__name__ in modular_map
|
||||
if not shared.opts.model_modular_enable:
|
||||
return False
|
||||
compatible = diffusion_pipeline.__class__.__name__ in modular_map
|
||||
if not compatible:
|
||||
shared.log.debug(f'Modular: source={diffusion_pipeline.__class__.__name__} incompatible pipeline')
|
||||
return compatible
|
||||
|
||||
|
||||
def convert_to_modular(diffusion_pipeline: diffusers.DiffusionPipeline) -> diffusers.ModularPipeline:
|
||||
@@ -33,8 +38,7 @@ def convert_to_modular(diffusion_pipeline: diffusers.DiffusionPipeline) -> diffu
|
||||
modular_pipe.update_components(**components_dct, **diffusion_pipeline.parameters)
|
||||
modular_pipe.original_pipe = diffusion_pipeline
|
||||
t1 = time.time()
|
||||
shared.log.debug(f'Modular: from={diffusion_pipeline.__class__.__name__} to={modular_pipe.__class__.__name__} time={t1 - t0:.2f}')
|
||||
|
||||
shared.log.debug(f'Modular: source={diffusion_pipeline.__class__.__name__} target={modular_pipe.__class__.__name__} time={t1 - t0:.2f}')
|
||||
"""
|
||||
for expected_input_param in modular_pipe.blocks.inputs:
|
||||
name = expected_input_param.name
|
||||
@@ -51,5 +55,5 @@ def convert_to_modular(diffusion_pipeline: diffusers.DiffusionPipeline) -> diffu
|
||||
|
||||
def restore_standard(modular_pipe):
|
||||
if hasattr(modular_pipe, 'original_pipe'):
|
||||
shared.log.debug(f'Modular: from={modular_pipe.__class__.__name__} to={modular_pipe.original_pipe.__class__.__name__}')
|
||||
shared.log.debug(f'Modular: source={modular_pipe.__class__.__name__} target={modular_pipe.original_pipe.__class__.__name__}')
|
||||
return modular_pipe.original_pipe
|
||||
|
||||
@@ -155,6 +155,8 @@ options_templates.update(options_section(('sd', "Model Loading"), {
|
||||
}))
|
||||
|
||||
options_templates.update(options_section(('model_options', "Model Options"), {
|
||||
"model_modular_sep": OptionInfo("<h2>Modular Pipelines</h2>", "", gr.HTML),
|
||||
"model_modular_enable": OptionInfo(False, "Enable modular pipelines (experimental)"),
|
||||
"model_sd3_sep": OptionInfo("<h2>Stable Diffusion 3.x</h2>", "", gr.HTML),
|
||||
"model_sd3_disable_te5": OptionInfo(False, "Disable T5 text encoder"),
|
||||
"model_h1_sep": OptionInfo("<h2>HiDream</h2>", "", gr.HTML),
|
||||
|
||||
Reference in New Issue
Block a user