prevent undefined variable

This commit is contained in:
Kohaku-Blueleaf 2024-02-19 14:43:07 +08:00 committed by GitHub
parent 5a8dd0c549
commit 4eb949625c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,8 @@ class NetworkModuleOFT(network.NetworkModule):
self.org_module: list[torch.Module] = [self.sd_module]
self.scale = 1.0
self.is_kohya = False
self.is_boft = False
# kohya-ss
if "oft_blocks" in weights.w.keys():
@ -31,13 +33,11 @@ class NetworkModuleOFT(network.NetworkModule):
self.dim = self.oft_blocks.shape[0] # lora dim
# LyCORIS OFT
elif "oft_diag" in weights.w.keys():
self.is_kohya = False
self.oft_blocks = weights.w["oft_diag"]
# self.alpha is unused
self.dim = self.oft_blocks.shape[1] # (num_blocks, block_size, block_size)
# LyCORIS BOFT
self.is_boft = False
if weights.w["oft_diag"].dim() == 4:
self.is_boft = True
self.rescale = weights.w.get('rescale', None)