lycoris-lora 1.8.0.dev8__tar.gz → 1.8.0.dev9__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-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/PKG-INFO +1 -1
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/loha.py +35 -12
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/PKG-INFO +1 -1
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/setup.py +1 -1
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/.gitignore +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/Algo.md +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/Change.md +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/Demo.md +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/LICENSE.md +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/README.md +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/better_conv.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/better_conv_extract.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/concept_neuron.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/locon_extract_test.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/locon_merge_test.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/singular_value_test.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/sparse_bias_test.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/time_test.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/experiments/weakre_speed.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/__init__.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/kohya/__init__.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/kohya/kohya_model_utils.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/kohya/kohya_utils.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/__init__.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/dylora.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/glokr.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/glora.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/ia3.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/locon.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/modules/lokr.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris/utils.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/SOURCES.txt +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/dependency_links.txt +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/not-zip-safe +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/requires.txt +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/top_level.txt +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/requirements.txt +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/setup.cfg +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/tools/extract_locon.py +0 -0
- {lycoris_lora-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/tools/merge.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris_lora
|
|
3
|
-
Version: 1.8.0.
|
|
3
|
+
Version: 1.8.0.dev9
|
|
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
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import math
|
|
2
|
+
from collections import OrderedDict, abc as container_abcs
|
|
2
3
|
|
|
3
4
|
import torch
|
|
4
5
|
import torch.nn as nn
|
|
@@ -102,6 +103,7 @@ class LohaModule(nn.Module):
|
|
|
102
103
|
self.cp=False
|
|
103
104
|
|
|
104
105
|
self.shape = org_module.weight.shape
|
|
106
|
+
self.scalar = nn.Parameter(torch.tensor(0.0))
|
|
105
107
|
if org_module.__class__.__name__ == 'Conv2d':
|
|
106
108
|
in_dim = org_module.in_channels
|
|
107
109
|
k_size = org_module.kernel_size
|
|
@@ -159,7 +161,7 @@ class LohaModule(nn.Module):
|
|
|
159
161
|
torch.nn.init.normal_(self.hada_w1_b, std=1)
|
|
160
162
|
torch.nn.init.normal_(self.hada_w1_a, std=0.1)
|
|
161
163
|
torch.nn.init.normal_(self.hada_w2_b, std=1)
|
|
162
|
-
torch.nn.init.
|
|
164
|
+
torch.nn.init.normal_(self.hada_w2_a, std=0.1)
|
|
163
165
|
|
|
164
166
|
self.multiplier = multiplier
|
|
165
167
|
self.org_module = [org_module] # remove in applying
|
|
@@ -187,25 +189,46 @@ class LohaModule(nn.Module):
|
|
|
187
189
|
drop = torch.rand(weight.size(0)) < self.rank_dropout
|
|
188
190
|
weight *= drop.view(-1, [1]*len(weight.shape[1:])).to(weight.device)
|
|
189
191
|
return weight
|
|
192
|
+
|
|
193
|
+
def state_dict(self, *args, destination=None, prefix='', keep_vars=False):
|
|
194
|
+
# TODO: Remove `args` and the parsing logic when BC allows.
|
|
195
|
+
if len(args) > 0:
|
|
196
|
+
if destination is None:
|
|
197
|
+
destination = args[0]
|
|
198
|
+
if len(args) > 1 and prefix == '':
|
|
199
|
+
prefix = args[1]
|
|
200
|
+
if len(args) > 2 and keep_vars is False:
|
|
201
|
+
keep_vars = args[2]
|
|
202
|
+
# DeprecationWarning is ignored by default
|
|
203
|
+
|
|
204
|
+
if destination is None:
|
|
205
|
+
destination = OrderedDict()
|
|
206
|
+
destination._metadata = OrderedDict()
|
|
207
|
+
|
|
208
|
+
local_metadata = dict(version=self._version)
|
|
209
|
+
if hasattr(destination, "_metadata"):
|
|
210
|
+
destination._metadata[prefix[:-1]] = local_metadata
|
|
211
|
+
|
|
212
|
+
destination[f'{prefix}alpha'] = self.alpha
|
|
213
|
+
destination[f'{prefix}hada_w1_a'] = self.hada_w1_a * self.scalar
|
|
214
|
+
destination[f'{prefix}hada_w1_b'] = self.hada_w1_b
|
|
215
|
+
destination[f'{prefix}hada_w2_a'] = self.hada_w2_a
|
|
216
|
+
destination[f'{prefix}hada_w2_b'] = self.hada_w2_b
|
|
217
|
+
if self.cp:
|
|
218
|
+
destination[f'{prefix}hada_t1'] = self.hada_t1
|
|
219
|
+
destination[f'{prefix}hada_t2'] = self.hada_t2
|
|
220
|
+
return destination
|
|
190
221
|
|
|
191
222
|
@torch.no_grad()
|
|
192
223
|
def apply_max_norm(self, max_norm, device=None):
|
|
193
|
-
orig_norm = self.get_weight().norm()
|
|
224
|
+
orig_norm = (self.get_weight()*self.scalar).norm()
|
|
194
225
|
norm = torch.clamp(orig_norm, max_norm/2)
|
|
195
226
|
desired = torch.clamp(norm, max=max_norm)
|
|
196
227
|
ratio = desired.cpu()/norm.cpu()
|
|
197
228
|
|
|
198
229
|
scaled = ratio.item() != 1.0
|
|
199
230
|
if scaled:
|
|
200
|
-
|
|
201
|
-
self.hada_w1_a *= ratio**(1/modules)
|
|
202
|
-
self.hada_w1_b *= ratio**(1/modules)
|
|
203
|
-
self.hada_w2_a *= ratio**(1/modules)
|
|
204
|
-
self.hada_w2_b *= ratio**(1/modules)
|
|
205
|
-
|
|
206
|
-
if self.cp:
|
|
207
|
-
self.hada_t1 *= ratio**(1/modules)
|
|
208
|
-
self.hada_t2 *= ratio**(1/modules)
|
|
231
|
+
self.scalar *= ratio
|
|
209
232
|
|
|
210
233
|
return scaled, orig_norm*ratio
|
|
211
234
|
|
|
@@ -220,7 +243,7 @@ class LohaModule(nn.Module):
|
|
|
220
243
|
)
|
|
221
244
|
weight = (
|
|
222
245
|
self.org_module[0].weight.data
|
|
223
|
-
+ self.get_weight(self.org_module[0].weight.data) * self.multiplier
|
|
246
|
+
+ self.get_weight(self.org_module[0].weight.data) * self.scalar * self.multiplier
|
|
224
247
|
)
|
|
225
248
|
bias = None if self.org_module[0].bias is None else self.org_module[0].bias.data
|
|
226
249
|
return self.op(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris-lora
|
|
3
|
-
Version: 1.8.0.
|
|
3
|
+
Version: 1.8.0.dev9
|
|
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='1.8.0.
|
|
6
|
+
version='1.8.0.dev9',
|
|
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
|
|
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-1.8.0.dev8 → lycoris_lora-1.8.0.dev9}/lycoris_lora.egg-info/dependency_links.txt
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
|