[REFACT]Refactor diffusion outputs to payload metadata (#4922)

Signed-off-by: bjf-frz <frz123db@gmail.com>
This commit is contained in:
bjf-frz authored and GitHub committed 2026-07-14 17:24:03 +08:00
1 parent 4b9d09cb87
commit 1a4a042a83
44 files changed
+1373 -478

No files matched your search

+14 -20
View File
@@ -541,13 +541,6 @@ _DIFFUSION_POST_PROCESS_FUNCS = {
"Krea2Pipeline": "get_krea2_post_process_func",
}
_DIFFUSION_ACTION_POST_PROCESS_FUNCS = {
# arch: action_post_process_func
# `action_post_process_func` function must be placed in {mod_folder}/{mod_relname}.py,
# where mod_folder and mod_relname are defined and mapped using `_DIFFUSION_MODELS` via the `arch` key.
"Cosmos3OmniDiffusersPipeline": "get_cosmos3_action_post_process_func",
}
_DIFFUSION_IR_OP_PRIORITY_FUNCS = {
# arch: ir_op_priority_func
# `ir_op_priority_func` function must be placed in {mod_folder}/{mod_relname}.py,
@@ -588,8 +581,8 @@ def register_diffusion_model(
class_name: str,
pre_process_func_name: str | None = None,
post_process_func_name: str | None = None,
action_post_process_func_name: str | None = None,
ir_op_priority_func_name: str | None = None,
action_post_process_func_name: str | None = None,
) -> None:
"""Register a diffusion model pipeline from an out-of-tree plugin.
@@ -608,13 +601,23 @@ def register_diffusion_model(
post_process_func_name: Optional name of the post-process function
located in *module_name*. Pass ``None`` to keep the existing
entry when replacing a built-in model.
action_post_process_func_name: Optional name of the action post-process
function located in *module_name*. Pass ``None`` to keep the
existing entry when replacing a built-in model.
ir_op_priority_func_name: Optional name of the IR op priority merge
function located in *module_name*. Pass ``None`` to keep the
existing entry when replacing a built-in model.
action_post_process_func_name: Deprecated compatibility-only keyword
for out-of-tree plugins. Action postprocess hooks are no longer
registered separately; move action handling into
``post_process_func_name`` and return a payload/metadata envelope.
"""
if action_post_process_func_name is not None:
logger.warning(
"Ignoring deprecated action_post_process_func_name=%r for diffusion "
"model %s. Move action postprocess logic into post_process_func_name "
"and return payload/metadata output.",
action_post_process_func_name,
model_arch,
)
# Register model class in DiffusionModelRegistry
DiffusionModelRegistry.register_model(
model_arch,
@@ -631,8 +634,6 @@ def register_diffusion_model(
_DIFFUSION_PRE_PROCESS_FUNCS[model_arch] = pre_process_func_name
if post_process_func_name is not None:
_DIFFUSION_POST_PROCESS_FUNCS[model_arch] = post_process_func_name
if action_post_process_func_name is not None:
_DIFFUSION_ACTION_POST_PROCESS_FUNCS[model_arch] = action_post_process_func_name
if ir_op_priority_func_name is not None:
_DIFFUSION_IR_OP_PRIORITY_FUNCS[model_arch] = ir_op_priority_func_name
@@ -665,13 +666,6 @@ def get_diffusion_post_process_func(od_config: OmniDiffusionConfig):
return _load_process_func(od_config, func_name)
def get_diffusion_action_post_process_func(od_config: OmniDiffusionConfig):
if od_config.model_class_name not in _DIFFUSION_ACTION_POST_PROCESS_FUNCS:
return None
func_name = _DIFFUSION_ACTION_POST_PROCESS_FUNCS[od_config.model_class_name]
return _load_process_func(od_config, func_name)
def get_diffusion_ir_op_priority_func(od_config: OmniDiffusionConfig):
if od_config.model_class_name not in _DIFFUSION_IR_OP_PRIORITY_FUNCS:
return None