lycoris-lora 1.9.0.dev6__tar.gz → 1.9.0.dev8__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.9.0.dev6 → lycoris_lora-1.9.0.dev8}/PKG-INFO +1 -1
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/__init__.py +4 -2
- lycoris_lora-1.9.0.dev8/lycoris/modules/full.py +85 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/locon.py +1 -1
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/loha.py +2 -2
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/lokr.py +1 -1
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/PKG-INFO +1 -1
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/SOURCES.txt +1 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/setup.py +2 -2
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/.gitignore +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/Algo.md +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/Change.md +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/Demo.md +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/LICENSE.md +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/README.md +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/better_conv.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/better_conv_extract.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/compare_norm.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/concept_neuron.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/locon_extract_test.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/locon_merge_test.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/loha_svd.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/singular_value_test.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/sparse_bias_test.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/time_test.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/experiments/weakre_speed.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/hyperdream_gen_weight.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/__init__.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/config.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/model_utils.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/original_unet.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/sdxl_model_util.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/sdxl_original_unet.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/kohya/utils.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/__init__.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/attention.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/dylora.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/glokr.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/glora.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/hyperlycoris.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/hypernet/__init__.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/hypernet/generater.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/hypernet/text_encoder.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/ia3.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/modules/norms.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/utils/__init__.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/utils/preset.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris/utils/xformers_utils.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/dependency_links.txt +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/not-zip-safe +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/requires.txt +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/lycoris_lora.egg-info/top_level.txt +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/requirements.txt +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/setup.cfg +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/tools/extract_locon.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/tools/merge.py +0 -0
- {lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/train_hyperdream.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris_lora
|
|
3
|
-
Version: 1.9.0.
|
|
3
|
+
Version: 1.9.0.dev8
|
|
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
|
|
@@ -19,6 +19,7 @@ from ..modules.lokr import LokrModule
|
|
|
19
19
|
from ..modules.dylora import DyLoraModule
|
|
20
20
|
from ..modules.glora import GLoRAModule
|
|
21
21
|
from ..modules.norms import NormModule
|
|
22
|
+
from ..modules.full import FullModule
|
|
22
23
|
|
|
23
24
|
from ..config import PRESET
|
|
24
25
|
from ..utils.preset import read_preset
|
|
@@ -46,6 +47,7 @@ def create_network(multiplier, network_dim, network_alpha, vae, text_encoder, un
|
|
|
46
47
|
'lokr': LokrModule,
|
|
47
48
|
'dylora': DyLoraModule,
|
|
48
49
|
'glora': GLoRAModule,
|
|
50
|
+
'full': FullModule,
|
|
49
51
|
}[algo]
|
|
50
52
|
|
|
51
53
|
if algo == 'glora' and conv_dim>0:
|
|
@@ -434,7 +436,7 @@ class LycorisNetwork(torch.nn.Module):
|
|
|
434
436
|
self.apply(make_ckpt)
|
|
435
437
|
pass
|
|
436
438
|
|
|
437
|
-
def prepare_optimizer_params(self, text_encoder_lr, unet_lr):
|
|
439
|
+
def prepare_optimizer_params(self, text_encoder_lr, unet_lr, learning_rate):
|
|
438
440
|
def enumerate_params(loras):
|
|
439
441
|
params = []
|
|
440
442
|
for lora in loras:
|
|
@@ -981,7 +983,7 @@ class IA3Network(torch.nn.Module):
|
|
|
981
983
|
self.apply(make_ckpt)
|
|
982
984
|
pass
|
|
983
985
|
|
|
984
|
-
def prepare_optimizer_params(self, text_encoder_lr, unet_lr):
|
|
986
|
+
def prepare_optimizer_params(self, text_encoder_lr, unet_lr, learning_rate):
|
|
985
987
|
def enumerate_params(loras):
|
|
986
988
|
params = []
|
|
987
989
|
for lora in loras:
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from weakref import ref
|
|
3
|
+
from collections import OrderedDict, abc as container_abcs
|
|
4
|
+
|
|
5
|
+
import torch
|
|
6
|
+
import torch.nn as nn
|
|
7
|
+
import torch.nn.functional as F
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FullModule(nn.Module):
|
|
11
|
+
"""
|
|
12
|
+
modifed from kohya-ss/sd-scripts/networks/lora:LoRAModule
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
lora_name, org_module: nn.Module,
|
|
18
|
+
multiplier=1.0,
|
|
19
|
+
lora_dim=4, alpha=1,
|
|
20
|
+
dropout=0., rank_dropout=0., module_dropout=0.,
|
|
21
|
+
use_cp=False, use_scalar=False,
|
|
22
|
+
**kwargs,
|
|
23
|
+
):
|
|
24
|
+
""" if alpha == 0 or None, alpha is rank (no scaling). """
|
|
25
|
+
super().__init__()
|
|
26
|
+
self.lora_name = lora_name
|
|
27
|
+
|
|
28
|
+
if isinstance(org_module, nn.Linear):
|
|
29
|
+
self.op = F.linear
|
|
30
|
+
self.dim = org_module.out_features
|
|
31
|
+
self.kw_dict = {}
|
|
32
|
+
elif isinstance(org_module, nn.Conv2d):
|
|
33
|
+
self.op = F.conv2d
|
|
34
|
+
self.dim = org_module.out_channels
|
|
35
|
+
self.kw_dict = {
|
|
36
|
+
"stride": org_module.stride,
|
|
37
|
+
"padding": org_module.padding,
|
|
38
|
+
"dilation": org_module.dilation,
|
|
39
|
+
"groups": org_module.groups,
|
|
40
|
+
}
|
|
41
|
+
else:
|
|
42
|
+
raise NotImplementedError
|
|
43
|
+
self.diff = nn.Parameter(torch.zeros_like(org_module.weight))
|
|
44
|
+
if org_module.bias is not None:
|
|
45
|
+
self.diff_b = nn.Parameter(torch.zeros_like(org_module.bias))
|
|
46
|
+
else:
|
|
47
|
+
self.diff_b = None
|
|
48
|
+
|
|
49
|
+
self.rank_dropout = rank_dropout
|
|
50
|
+
self.module_dropout = module_dropout
|
|
51
|
+
|
|
52
|
+
self.multiplier = multiplier
|
|
53
|
+
self.org_module = [org_module]
|
|
54
|
+
|
|
55
|
+
def apply_to(self, **kwargs):
|
|
56
|
+
self.org_forward = self.org_module[0].forward
|
|
57
|
+
self.org_module[0].forward = self.forward
|
|
58
|
+
|
|
59
|
+
def make_weight(self, scale = 1, device=None):
|
|
60
|
+
drop = (
|
|
61
|
+
torch.rand(self.dim, device=device) < self.rank_dropout
|
|
62
|
+
if self.rank_dropout and self.training
|
|
63
|
+
else 1
|
|
64
|
+
)
|
|
65
|
+
org_weight = self.org_module[0].weight.to(device)
|
|
66
|
+
weight = self.diff.to(device) * drop * scale
|
|
67
|
+
weight = weight + org_weight
|
|
68
|
+
|
|
69
|
+
if self.diff_b is not None:
|
|
70
|
+
org_bias = self.org_module[0].bias.to(device)
|
|
71
|
+
bias = self.diff_b.to(device) * drop * scale
|
|
72
|
+
bias = bias + org_bias
|
|
73
|
+
else:
|
|
74
|
+
bias = None
|
|
75
|
+
return weight, bias
|
|
76
|
+
|
|
77
|
+
def forward(self, x):
|
|
78
|
+
if self.module_dropout and self.training:
|
|
79
|
+
if torch.rand(1) < self.module_dropout:
|
|
80
|
+
return self.org_forward(x)
|
|
81
|
+
scale = self.multiplier
|
|
82
|
+
|
|
83
|
+
w, b = self.make_weight(scale, x.device)
|
|
84
|
+
kw_dict = self.kw_dict | {"weight": w, "bias": b}
|
|
85
|
+
return self.op(x, **kw_dict)
|
|
@@ -72,7 +72,7 @@ class LoConModule(nn.Module):
|
|
|
72
72
|
if use_scalar:
|
|
73
73
|
self.scalar = nn.Parameter(torch.tensor(0.0))
|
|
74
74
|
else:
|
|
75
|
-
self.scalar = 1.0
|
|
75
|
+
self.scalar = torch.tensor(1.0)
|
|
76
76
|
# same as microsoft's
|
|
77
77
|
torch.nn.init.kaiming_uniform_(self.lora_down.weight, a=math.sqrt(5))
|
|
78
78
|
if use_scalar:
|
|
@@ -157,7 +157,7 @@ class LohaModule(nn.Module):
|
|
|
157
157
|
if use_scalar:
|
|
158
158
|
self.scalar = nn.Parameter(torch.tensor(0.0))
|
|
159
159
|
else:
|
|
160
|
-
self.scalar = 1.0
|
|
160
|
+
self.scalar = torch.tensor(1.0)
|
|
161
161
|
# Need more experiments on init method
|
|
162
162
|
if self.cp:
|
|
163
163
|
torch.nn.init.normal_(self.hada_t1, std=0.1)
|
|
@@ -262,4 +262,4 @@ class LohaModule(nn.Module):
|
|
|
262
262
|
weight.view(self.shape),
|
|
263
263
|
bias,
|
|
264
264
|
**self.extra_args
|
|
265
|
-
)
|
|
265
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lycoris-lora
|
|
3
|
-
Version: 1.9.0.
|
|
3
|
+
Version: 1.9.0.dev8
|
|
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.9.0.
|
|
6
|
+
version='1.9.0.dev8',
|
|
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',
|
|
@@ -15,4 +15,4 @@ setup(
|
|
|
15
15
|
'diffusers',
|
|
16
16
|
'transformers'
|
|
17
17
|
],
|
|
18
|
-
)
|
|
18
|
+
)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/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
|
{lycoris_lora-1.9.0.dev6 → lycoris_lora-1.9.0.dev8}/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
|
|
File without changes
|