Update calculate_weight call to use new location to remove warning (backwards compatible)

This commit is contained in:
Jedrzej Kosinski
2024-08-23 04:01:08 -05:00
parent c5c27807f0
commit 651ccfecf7
+7 -1
View File
@@ -66,6 +66,12 @@ class ModelPatcherAndInjector(ModelPatcher):
self.motion_injection_params: InjectionParams = InjectionParams()
self.sample_settings: SampleSettings = SampleSettings()
self.motion_models: MotionModelGroup = None
# backwards-compatible calculate_weight
if hasattr(comfy.lora, "calculate_weight"):
self.do_calculate_weight = comfy.lora.calculate_weight
else:
self.do_calculate_weight = self.calculate_weight
def clone(self, hooks_only=False):
cloned = ModelPatcherAndInjector(self)
@@ -379,7 +385,7 @@ class ModelPatcherAndInjector(ModelPatcher):
# TODO: handle model_params_lowvram stuff if necessary
temp_weight = comfy.model_management.cast_to_device(weight, weight.device, torch.float32, copy=True)
out_weight = self.calculate_weight(combined_patches[key], temp_weight, key).to(weight.dtype)
out_weight = self.do_calculate_weight(combined_patches[key], temp_weight, key).to(weight.dtype)
if self.lora_hook_mode == LoraHookMode.MAX_SPEED:
self.cached_hooked_patches.setdefault(lora_hooks, {})
self.cached_hooked_patches[lora_hooks][key] = out_weight