Skip to content

Commit ebcb6ef

Browse files
committed
Update requirements and others
1 parent 72f9fdc commit ebcb6ef

6 files changed

+44
-16
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ If you come across a `FileNotFoundError`, it is likely due to an installation is
483483
* 2023/07/29 (v21.8.6)
484484
- Merge latest sd-scripts updates.
485485
- Allow DB training on SDXL models. Unsupported but appear to work.
486+
- Fix finetuning latent caching issue when doing SDXL models in fp16
486487
* 2023/07/27 (v21.8.5)
487488
- Backrev the LyCORIS module version due to bug reports.
488489
* 2023/07/27 (v21.8.4)

finetune_gui.py

+3
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ def train_model(
450450
# run_cmd += f' --flip_aug'
451451
if full_path:
452452
run_cmd += f' --full_path'
453+
if sdxl_no_half_vae:
454+
log.info('Using mixed_precision = no because no half vae is selected...')
455+
run_cmd += f' --mixed_precision="no"'
453456

454457
log.info(run_cmd)
455458

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ftfy==6.1.1
1010
gradio==3.36.1
1111
huggingface-hub==0.15.1
1212
lion-pytorch==0.0.6
13-
lycoris_lora==1.8.0
13+
lycoris_lora==1.8.3
1414
# for loading Diffusers' SDXL
1515
invisible-watermark==0.2.0
1616
# open clip for SDXL

requirements_windows_torch2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
torch==2.0.1+cu118 torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu118 # no_verify
22
xformers==0.0.20
3+
# bitsandbytes==0.35.0
34
https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.40.1.post1-py3-none-win_amd64.whl # no_verify
45
tensorboard==2.12.3 tensorflow==2.12.0
56
-r requirements.txt

tools/extract_locon.py

+36-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#
2-
# From: https://raw.githubusercontent.com/KohakuBlueleaf/LoCon/main/extract_locon.py
3-
#
4-
1+
import os, sys
2+
sys.path.insert(0, os.getcwd())
53
import argparse
64

5+
76
def get_args():
87
parser = argparse.ArgumentParser()
98
parser.add_argument(
@@ -29,11 +28,15 @@ def get_args():
2928
parser.add_argument(
3029
"--mode",
3130
help=(
32-
'extraction mode, can be "fixed", "threshold", "ratio", "percentile". '
31+
'extraction mode, can be "fixed", "threshold", "ratio", "quantile". '
3332
'If not "fixed", network_dim and conv_dim will be ignored'
3433
),
3534
default='fixed', type=str
3635
)
36+
parser.add_argument(
37+
"--safetensors", help='use safetensors to save locon model',
38+
default=True, action="store_true"
39+
)
3740
parser.add_argument(
3841
"--linear_dim", help="network dim for linear layer in fixed mode",
3942
default=1, type=int
@@ -59,20 +62,34 @@ def get_args():
5962
default=0., type=float
6063
)
6164
parser.add_argument(
62-
"--linear_percentile", help="singular value percentile for linear layer percentile mode",
65+
"--linear_quantile", help="singular value quantile for linear layer quantile mode",
6366
default=1., type=float
6467
)
6568
parser.add_argument(
66-
"--conv_percentile", help="singular value percentile for conv layer percentile mode",
69+
"--conv_quantile", help="singular value quantile for conv layer quantile mode",
6770
default=1., type=float
6871
)
72+
parser.add_argument(
73+
"--use_sparse_bias", help="enable sparse bias",
74+
default=False, action="store_true"
75+
)
76+
parser.add_argument(
77+
"--sparsity", help="sparsity for sparse bias",
78+
default=0.98, type=float
79+
)
80+
parser.add_argument(
81+
"--disable_cp", help="don't use cp decomposition",
82+
default=False, action="store_true"
83+
)
6984
return parser.parse_args()
7085
ARGS = get_args()
7186

72-
from locon.utils import extract_diff
73-
from locon.kohya_model_utils import load_models_from_stable_diffusion_checkpoint
87+
88+
from lycoris.utils import extract_diff
89+
from lycoris.kohya.model_utils import load_models_from_stable_diffusion_checkpoint
7490

7591
import torch
92+
from safetensors.torch import save_file
7693

7794

7895
def main():
@@ -84,22 +101,28 @@ def main():
84101
'fixed': args.linear_dim,
85102
'threshold': args.linear_threshold,
86103
'ratio': args.linear_ratio,
87-
'percentile': args.linear_percentile,
104+
'quantile': args.linear_quantile,
88105
}[args.mode]
89106
conv_mode_param = {
90107
'fixed': args.conv_dim,
91108
'threshold': args.conv_threshold,
92109
'ratio': args.conv_ratio,
93-
'percentile': args.conv_percentile,
110+
'quantile': args.conv_quantile,
94111
}[args.mode]
95112

96113
state_dict = extract_diff(
97114
base, db,
98115
args.mode,
99116
linear_mode_param, conv_mode_param,
100-
args.device
117+
args.device,
118+
args.use_sparse_bias, args.sparsity,
119+
not args.disable_cp
101120
)
102-
torch.save(state_dict, args.output_name)
121+
122+
if args.safetensors:
123+
save_file(state_dict, args.output_name)
124+
else:
125+
torch.save(state_dict, args.output_name)
103126

104127

105128
if __name__ == '__main__':

tools/merge_lycoris.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def get_args():
3737
ARGS = get_args()
3838

3939

40-
from lycoris_utils import merge
41-
from lycoris.kohya_model_utils import (
40+
from lycoris.utils import merge
41+
from lycoris.kohya.model_utils import (
4242
load_models_from_stable_diffusion_checkpoint,
4343
save_stable_diffusion_checkpoint,
4444
load_file

0 commit comments

Comments
 (0)