Version 0.6.0
Updates at 4 Apr. 2023, 2023/4/4:
-
The learning rate and dim (rank) of each block may not work with other modules (LyCORIS, etc.) because the module needs to be changed.
-
Fix some bugs and add some features.
- Fix an issue that
.jsonformat dataset config files cannot be read. issue #351 Thanks to rockerBOO! - Raise an error when an invalid
--lr_warmup_stepsoption is specified (when warmup is not valid for the specified scheduler). PR #364 Thanks to shirayu! - Add
min_snr_gammato metadata intrain_network.py. PR #373 Thanks to rockerBOO! - Fix the data type handling in
fine_tune.py. This may fix an error that occurs in some environments when using xformers, npz format cache, and mixed_precision.
- Fix an issue that
-
Add options to
train_network.pyto specify block weights for learning rates. PR #355 Thanks to u-haru for the great contribution!- Specify the weights of 25 blocks for the full model.
- No LoRA corresponds to the first block, but 25 blocks are specified for compatibility with 'LoRA block weight' etc. Also, if you do not expand to conv2d3x3, some blocks do not have LoRA, but please specify 25 values for the argument for consistency.
- Specify the following arguments with
--network_args. down_lr_weight: Specify the learning rate weight of the down blocks of U-Net. The following can be specified.- The weight for each block: Specify 12 numbers such as
"down_lr_weight=0,0,0,0,0,0,1,1,1,1,1,1". - Specify from preset: Specify such as
"down_lr_weight=sine"(the weights by sine curve). sine, cosine, linear, reverse_linear, zeros can be specified. Also, if you add+numbersuch as"down_lr_weight=cosine+.25", the specified number is added (such as 0.25~1.25).
- The weight for each block: Specify 12 numbers such as
mid_lr_weight: Specify the learning rate weight of the mid block of U-Net. Specify one number such as"down_lr_weight=0.5".up_lr_weight: Specify the learning rate weight of the up blocks of U-Net. The same as down_lr_weight.- If you omit the some arguments, the 1.0 is used. Also, if you set the weight to 0, the LoRA modules of that block are not created.
block_lr_zero_threshold: If the weight is not more than this value, the LoRA module is not created. The default is 0.
- Specify the weights of 25 blocks for the full model.
-
Add options to
train_network.pyto specify block dims (ranks) for variable rank.- Specify 25 values for the full model of 25 blocks. Some blocks do not have LoRA, but specify 25 values always.
- Specify the following arguments with
--network_args. block_dims: Specify the dim (rank) of each block. Specify 25 numbers such as"block_dims=2,2,2,2,4,4,4,4,6,6,6,6,8,6,6,6,6,4,4,4,4,2,2,2,2".block_alphas: Specify the alpha of each block. Specify 25 numbers as with block_dims. If omitted, the value of network_alpha is used.conv_block_dims: Expand LoRA to Conv2d 3x3 and specify the dim (rank) of each block.conv_block_alphas: Specify the alpha of each block when expanding LoRA to Conv2d 3x3. If omitted, the value of conv_alpha is used.
-
階層別学習率、階層別dim(rank)についてはモジュール側の変更が必要なため、当リポジトリ内のnetworkモジュール以外(LyCORISなど)では現在は動作しないと思われます。
-
いくつかのバグ修正、機能追加を行いました。
.json形式のdataset設定ファイルを読み込めない不具合を修正しました。 issue #351 rockerBOO 氏に感謝します。- 無効な
--lr_warmup_stepsオプション(指定したスケジューラでwarmupが無効な場合)を指定している場合にエラーを出すようにしました。 PR #364 shirayu 氏に感謝します。 train_network.pyでmin_snr_gammaをメタデータに追加しました。 PR #373 rockerBOO 氏に感謝します。fine_tune.pyでデータ型の取り扱いが誤っていたのを修正しました。一部の環境でxformersを使い、npz形式のキャッシュ、mixed_precisionで学習した時にエラーとなる不具合が解消されるかもしれません。
-
階層別学習率を
train_network.pyで指定できるようになりました。PR #355 u-haru 氏の多大な貢献に感謝します。- フルモデルの25個のブロックの重みを指定できます。
- 最初のブロックに該当するLoRAは存在しませんが、階層別LoRA適用等との互換性のために25個としています。またconv2d3x3に拡張しない場合も一部のブロックにはLoRAが存在しませんが、記述を統一するため常に25個の値を指定してください。
---network_argsで以下の引数を指定してください。
- 最初のブロックに該当するLoRAは存在しませんが、階層別LoRA適用等との互換性のために25個としています。またconv2d3x3に拡張しない場合も一部のブロックにはLoRAが存在しませんが、記述を統一するため常に25個の値を指定してください。
down_lr_weight: U-Netのdown blocksの学習率の重みを指定します。以下が指定可能です。- ブロックごとの重み :
"down_lr_weight=0,0,0,0,0,0,1,1,1,1,1,1"のように12個の数値を指定します。 - プリセットからの指定 :
"down_lr_weight=sine"のように指定します(サインカーブで重みを指定します)。sine, cosine, linear, reverse_linear, zeros が指定可能です。また"down_lr_weight=cosine+.25"のように+数値を追加すると、指定した数値を加算します(0.25~1.25になります)。
- ブロックごとの重み :
mid_lr_weight: U-Netのmid blockの学習率の重みを指定します。"down_lr_weight=0.5"のように数値を一つだけ指定します。up_lr_weight: U-Netのup blocksの学習率の重みを指定します。down_lr_weightと同様です。- 指定を省略した部分は1.0として扱われます。また重みを0にするとそのブロックのLoRAモジュールは作成されません。
block_lr_zero_threshold: 重みがこの値以下の場合、LoRAモジュールを作成しません。デフォルトは0です。
- フルモデルの25個のブロックの重みを指定できます。
-
階層別dim (rank)を
train_network.pyで指定できるようになりました。- フルモデルの25個のブロックのdim (rank)を指定できます。階層別学習率と同様に一部のブロックにはLoRAが存在しない場合がありますが、常に25個の値を指定してください。
--network_argsで以下の引数を指定してください。block_dims: 各ブロックのdim (rank)を指定します。"block_dims=2,2,2,2,4,4,4,4,6,6,6,6,8,6,6,6,6,4,4,4,4,2,2,2,2"のように25個の数値を指定します。block_alphas: 各ブロックのalphaを指定します。block_dimsと同様に25個の数値を指定します。省略時はnetwork_alphaの値が使用されます。conv_block_dims: LoRAをConv2d 3x3に拡張し、各ブロックのdim (rank)を指定します。conv_block_alphas: LoRAをConv2d 3x3に拡張したときの各ブロックのalphaを指定します。省略時はconv_alphaの値が使用されます。
-
階層別学習率コマンドライン指定例 / Examples of block learning rate command line specification:
--network_args "down_lr_weight=0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5" "mid_lr_weight=2.0" "up_lr_weight=1.5,1.5,1.5,1.5,1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5"--network_args "block_lr_zero_threshold=0.1" "down_lr_weight=sine+.5" "mid_lr_weight=1.5" "up_lr_weight=cosine+.5" -
階層別学習率tomlファイル指定例 / Examples of block learning rate toml file specification
network_args = [ "down_lr_weight=0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5", "mid_lr_weight=2.0", "up_lr_weight=1.5,1.5,1.5,1.5,1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5",]network_args = [ "block_lr_zero_threshold=0.1", "down_lr_weight=sine+.5", "mid_lr_weight=1.5", "up_lr_weight=cosine+.5", ] -
階層別dim (rank)コマンドライン指定例 / Examples of block dim (rank) command line specification:
--network_args "block_dims=2,4,4,4,8,8,8,8,12,12,12,12,16,12,12,12,12,8,8,8,8,4,4,4,2"--network_args "block_dims=2,4,4,4,8,8,8,8,12,12,12,12,16,12,12,12,12,8,8,8,8,4,4,4,2" "conv_block_dims=2,2,2,2,4,4,4,4,6,6,6,6,8,6,6,6,6,4,4,4,4,2,2,2,2"--network_args "block_dims=2,4,4,4,8,8,8,8,12,12,12,12,16,12,12,12,12,8,8,8,8,4,4,4,2" "block_alphas=2,2,2,2,4,4,4,4,6,6,6,6,8,6,6,6,6,4,4,4,4,2,2,2,2" -
階層別dim (rank)tomlファイル指定例 / Examples of block dim (rank) toml file specification
network_args = [ "block_dims=2,4,4,4,8,8,8,8,12,12,12,12,16,12,12,12,12,8,8,8,8,4,4,4,2",]network_args = [ "block_dims=2,4,4,4,8,8,8,8,12,12,12,12,16,12,12,12,12,8,8,8,8,4,4,4,2", "block_alphas=2,2,2,2,4,4,4,4,6,6,6,6,8,6,6,6,6,4,4,4,4,2,2,2,2",]