fix lora with latest torch

This commit is contained in:
Vladimir Mandic
2024-01-24 13:03:52 -05:00
parent dad7fe7dcf
commit ca7074839f
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -90,16 +90,17 @@ class NetworkModule:
self.scale = weights.w["scale"].item() if "scale" in weights.w else None
def multiplier(self):
unet_multiplier = 3 * [self.network.unet_multiplier] if not isinstance(self.network.unet_multiplier, list) else self.network.unet_multiplier
if 'transformer' in self.sd_key[:20]:
return self.network.te_multiplier
if "down_blocks" in self.sd_key:
return self.network.unet_multiplier[0]
return unet_multiplier[0]
if "mid_block" in self.sd_key:
return self.network.unet_multiplier[1]
return unet_multiplier[1]
if "up_blocks" in self.sd_key:
return self.network.unet_multiplier[2]
return unet_multiplier[2]
else:
return self.network.unet_multiplier[0]
return unet_multiplier[0]
def calc_scale(self):
if self.scale is not None:
+1 -1
View File
@@ -303,7 +303,7 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
if len(self.weight.shape) == 4 and self.weight.shape[1] == 9:
# inpainting model. zero pad updown to make channel[1] 4 to 9
updown = torch.nn.functional.pad(updown, (0, 0, 0, 0, 0, 5)) # pylint: disable=not-callable
self.weight += updown
self.weight = torch.nn.Parameter(self.weight + updown)
if ex_bias is not None and hasattr(self, 'bias'):
if self.bias is None:
self.bias = torch.nn.Parameter(ex_bias)