Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Make it easy for models to process the unet state dict on load.

comfyanonymousce67dcbcdabe
diff --git a/comfy/model_base.py b/comfy/model_base.py
index 37bf24bb8..772e26934 100644
--- a/comfy/model_base.py
+++ b/comfy/model_base.py
@@ -121,6 +121,7 @@ class BaseModel(torch.nn.Module):
if k.startswith(unet_prefix):
to_load[k[len(unet_prefix):]] = sd.pop(k)
+ to_load = self.model_config.process_unet_state_dict(to_load)
m, u = self.diffusion_model.load_state_dict(to_load, strict=False)
if len(m) > 0:
print("unet missing:", m)
diff --git a/comfy/supported_models_base.py b/comfy/supported_models_base.py
index 88a1d7fde..6dfae0343 100644
--- a/comfy/supported_models_base.py
+++ b/comfy/supported_models_base.py
@@ -53,6 +53,9 @@ class BASE:
def process_clip_state_dict(self, state_dict):
return state_dict
+ def process_unet_state_dict(self, state_dict):
+ return state_dict
+
def process_clip_state_dict_for_saving(self, state_dict):
replace_prefix = {"": "cond_stage_model."}
return utils.state_dict_prefix_replace(state_dict, replace_prefix)