lycoris-lora 2.0.0.dev9__tar.gz → 2.0.0.dev11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/PKG-INFO +1 -1
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/__init__.py +1 -1
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/model_utils.py +2 -2
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/sdxl_model_util.py +2 -2
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/diag_oft.py +12 -21
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/full.py +1 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/utils/__init__.py +2 -1
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/PKG-INFO +1 -1
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/setup.py +1 -1
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/LICENSE.md +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/README.md +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/__init__.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/config.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/hcp/__init__.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/hcp/base.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/hcp/loha.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/hcp/lokr.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/original_unet.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/sdxl_original_unet.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/kohya/utils.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/__init__.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/attention.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/base.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/dylora.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/glokr.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/glora.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/hypernet/__init__.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/hypernet/generater.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/hypernet/text_encoder.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/ia3.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/locon.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/loha.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/lokr.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/norms.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/utils/logger.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/utils/preset.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/utils/xformers_utils.py +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/SOURCES.txt +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/dependency_links.txt +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/not-zip-safe +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/requires.txt +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/top_level.txt +0 -0
- {lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris_lora
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev11
|
|
4
4
|
Summary: Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion
|
|
5
5
|
Home-page: https://github.com/KohakuBlueleaf/LyCORIS
|
|
6
6
|
Author: Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao
|
|
@@ -63,7 +63,7 @@ def create_network(multiplier, network_dim, network_alpha, vae, text_encoder, un
|
|
|
63
63
|
use_scalar = str_bool(kwargs.get('use_scalar', False))
|
|
64
64
|
block_size = int(kwargs.get('block_size', 4) or 4)
|
|
65
65
|
train_norm = str_bool(kwargs.get('train_norm', False))
|
|
66
|
-
constrain =
|
|
66
|
+
constrain = float(kwargs.get('constrain', 0) or 0)
|
|
67
67
|
rescaled = str_bool(kwargs.get('rescaled', False))
|
|
68
68
|
|
|
69
69
|
if algo == 'glora' and conv_dim>0:
|
|
@@ -1028,7 +1028,7 @@ def load_models_from_stable_diffusion_checkpoint(v2, ckpt_path, device="cpu", dt
|
|
|
1028
1028
|
transformers_version="4.25.0.dev0",
|
|
1029
1029
|
)
|
|
1030
1030
|
text_model = CLIPTextModel._from_config(cfg)
|
|
1031
|
-
info = text_model.load_state_dict(converted_text_encoder_checkpoint)
|
|
1031
|
+
info = text_model.load_state_dict(converted_text_encoder_checkpoint, strict=False)
|
|
1032
1032
|
else:
|
|
1033
1033
|
converted_text_encoder_checkpoint = convert_ldm_clip_checkpoint_v1(state_dict)
|
|
1034
1034
|
|
|
@@ -1057,7 +1057,7 @@ def load_models_from_stable_diffusion_checkpoint(v2, ckpt_path, device="cpu", dt
|
|
|
1057
1057
|
torch_dtype="float32",
|
|
1058
1058
|
)
|
|
1059
1059
|
text_model = CLIPTextModel._from_config(cfg)
|
|
1060
|
-
info = text_model.load_state_dict(converted_text_encoder_checkpoint)
|
|
1060
|
+
info = text_model.load_state_dict(converted_text_encoder_checkpoint, strict=False)
|
|
1061
1061
|
print("loading text encoder:", info)
|
|
1062
1062
|
|
|
1063
1063
|
return text_model, vae, unet
|
|
@@ -228,11 +228,11 @@ def load_models_from_sdxl_checkpoint(model_version, ckpt_path, map_location):
|
|
|
228
228
|
elif k.startswith("conditioner.embedders.1.model."):
|
|
229
229
|
te2_sd[k] = state_dict.pop(k)
|
|
230
230
|
|
|
231
|
-
info1 = text_model1.load_state_dict(te1_sd)
|
|
231
|
+
info1 = text_model1.load_state_dict(te1_sd, strict=False)
|
|
232
232
|
print("text encoder 1:", info1)
|
|
233
233
|
|
|
234
234
|
converted_sd, logit_scale = convert_sdxl_text_encoder_2_checkpoint(te2_sd, max_length=77)
|
|
235
|
-
info2 = text_model2.load_state_dict(converted_sd)
|
|
235
|
+
info2 = text_model2.load_state_dict(converted_sd, strict=False)
|
|
236
236
|
print("text encoder 2:", info2)
|
|
237
237
|
|
|
238
238
|
# prepare vae
|
|
@@ -47,15 +47,10 @@ class DiagOFTModule(ModuleCustomSD):
|
|
|
47
47
|
self.block_size, self.block_num = factorization(out_dim, lora_dim)
|
|
48
48
|
# block_num > block_size
|
|
49
49
|
self.rescaled = rescaled
|
|
50
|
-
self.constrain = constrain
|
|
51
|
-
|
|
52
|
-
#follow kohya's naming to reduce more works in inference
|
|
53
|
-
self.oft_blocks = nn.Parameter(torch.zeros(self.block_num, self.block_size, self.block_size))
|
|
54
|
-
else:
|
|
55
|
-
# For non-constrained OFT, different formulation so use different naming
|
|
56
|
-
self.oft_diag = nn.Parameter(torch.zeros(self.block_num, self.block_size, self.block_size))
|
|
50
|
+
self.constrain = constrain * out_dim
|
|
51
|
+
self.oft_blocks = nn.Parameter(torch.zeros(self.block_num, self.block_size, self.block_size))
|
|
57
52
|
if rescaled:
|
|
58
|
-
self.rescale = nn.Parameter(torch.ones(self.block_num, self.block_size))
|
|
53
|
+
self.rescale = nn.Parameter(torch.ones(self.block_num, self.block_size, 1))
|
|
59
54
|
|
|
60
55
|
self.rank_dropout = rank_dropout
|
|
61
56
|
self.rank_dropout_scale = rank_dropout_scale
|
|
@@ -78,24 +73,20 @@ class DiagOFTModule(ModuleCustomSD):
|
|
|
78
73
|
}
|
|
79
74
|
|
|
80
75
|
def get_r(self):
|
|
76
|
+
I = self.I
|
|
77
|
+
# for Q = -Q^T
|
|
78
|
+
q = self.oft_blocks - self.oft_blocks.transpose(1, 2)
|
|
79
|
+
normed_q = q
|
|
81
80
|
if self.constrain > 0:
|
|
82
|
-
I = self.I
|
|
83
|
-
# for Q = -Q^T
|
|
84
|
-
q = self.oft_blocks - self.oft_blocks.transpose(1, 2)
|
|
85
81
|
q_norm = torch.norm(q) + 1e-8
|
|
86
82
|
if q_norm > self.constrain:
|
|
87
83
|
normed_q = q * self.constrain / q_norm
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# assume we have autocast enabled
|
|
91
|
-
# use float() to prevent unsupported type
|
|
92
|
-
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
|
93
|
-
else:
|
|
94
|
-
r = self.oft_diag
|
|
84
|
+
# use float() to prevent unsupported type
|
|
85
|
+
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
|
95
86
|
|
|
96
87
|
if self.rescaled:
|
|
97
88
|
# Noted: not implemented in Kohya
|
|
98
|
-
r = self.rescale
|
|
89
|
+
r = self.rescale * r
|
|
99
90
|
return r
|
|
100
91
|
|
|
101
92
|
def make_weight(self, scale = 1, device=None):
|
|
@@ -112,7 +103,7 @@ class DiagOFTModule(ModuleCustomSD):
|
|
|
112
103
|
# Init R=0, so add I on it to ensure the output of step0 is original model output
|
|
113
104
|
weight = torch.einsum(
|
|
114
105
|
"k n m, k n ... -> k m ...",
|
|
115
|
-
r * scale + self.I, org_weight
|
|
106
|
+
r * scale + (1-scale) * self.I, org_weight
|
|
116
107
|
)
|
|
117
108
|
weight = rearrange(weight, 'k m ... -> (k m) ...')
|
|
118
109
|
return weight
|
|
@@ -137,5 +128,5 @@ class DiagOFTModule(ModuleCustomSD):
|
|
|
137
128
|
scale = self.multiplier
|
|
138
129
|
|
|
139
130
|
w = self.make_weight(scale, x.device)
|
|
140
|
-
kw_dict = self.kw_dict | {"weight": w}
|
|
131
|
+
kw_dict = self.kw_dict | {"weight": w, "bias": self.org_module[0].bias}
|
|
141
132
|
return self.op(x, **kw_dict)
|
|
@@ -462,7 +462,8 @@ def rebuild_weight(module_type, params, orig_weight, orig_bias, scale=1):
|
|
|
462
462
|
merged = orig_weight + rebuild * scale
|
|
463
463
|
merged_bias = orig_bias + rebuild_b * scale
|
|
464
464
|
else:
|
|
465
|
-
|
|
465
|
+
merged = orig_weight
|
|
466
|
+
merged_bias = orig_bias
|
|
466
467
|
|
|
467
468
|
return merged, merged_bias
|
|
468
469
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris-lora
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev11
|
|
4
4
|
Summary: Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion
|
|
5
5
|
Home-page: https://github.com/KohakuBlueleaf/LyCORIS
|
|
6
6
|
Author: Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao
|
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|
|
3
3
|
setup(
|
|
4
4
|
name='lycoris_lora',
|
|
5
5
|
packages=find_packages(),
|
|
6
|
-
version='2.0.0.
|
|
6
|
+
version='2.0.0.dev11',
|
|
7
7
|
url='https://github.com/KohakuBlueleaf/LyCORIS',
|
|
8
8
|
description='Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion',
|
|
9
9
|
author='Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris/modules/hypernet/text_encoder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lycoris_lora-2.0.0.dev9 → lycoris_lora-2.0.0.dev11}/lycoris_lora.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|