Skip to content

Releases: kohya-ss/sd-scripts

Version 0.5.4

03 Apr 12:17
f037b09

Choose a tag to compare

Updates at 1 Apr. 2023, 2023/4/1:

  • Fix an issue that merge_lora.py does not work with the latest version.
  • Fix an issue that merge_lora.py does not merge Conv2d3x3 weights.
  • 最新のバージョンでmerge_lora.py が動作しない不具合を修正しました。
  • merge_lora.pyno module found for LoRA weight: ... と表示され Conv2d3x3 拡張の重みがマージされない不具合を修正しました。

Updates at 31 Mar. 2023, 2023/3/31:

  • Fix an issue that the VRAM usage temporarily increases when loading a model in train_network.py.
  • Fix an issue that an error occurs when loading a .safetensors model in train_network.py. #354
  • train_network.py でモデル読み込み時にVRAM使用量が一時的に大きくなる不具合を修正しました。
  • train_network.py.safetensors 形式のモデルを読み込むとエラーになる不具合を修正しました。#354

Updates at 30 Mar. 2023, 2023/3/30:

  • Support P+ training. Thank you jakaline-dev!

    • See #327 for details.
    • Use train_textual_inversion_XTI.py for training. The usage is almost the same as train_textual_inversion.py. However, sample image generation during training is not supported.
    • Use gen_img_diffusers.py for image generation (I think Web UI is not supported). Specify the embedding with --XTI_embeddings option.
  • Reduce RAM usage at startup in train_network.py. #332 Thank you guaneec!

  • Support pre-merge for LoRA in gen_img_diffusers.py. Specify --network_merge option. Note that the --am option of the prompt option is no longer available with this option.

  • P+ の学習に対応しました。jakaline-dev氏に感謝します。

    • 詳細は #327 をご参照ください。
    • 学習には train_textual_inversion_XTI.py を使用します。使用法は train_textual_inversion.py とほぼ同じです。た
      だし学習中のサンプル生成には対応していません。
    • 画像生成には gen_img_diffusers.py を使用してください(Web UIは対応していないと思われます)。--XTI_embeddings オプションで学習したembeddingを指定してください。
  • train_network.py で起動時のRAM使用量を削減しました。#332 guaneec氏に感謝します。

  • gen_img_diffusers.py でLoRAの事前マージに対応しました。--network_merge オプションを指定してください。なおプロンプトオプションの --am は使用できなくなります。

Version 0.5.3

30 Mar 12:46
b996f5a

Choose a tag to compare

Updates at 28 Mar. 2023, 2023/3/28:

  • Fix an issue that the training script crashes when max_data_loader_n_workers is 0.
  • max_data_loader_n_workers が0の時に学習スクリプトがエラーとなる不具合を修正しました。

Updates at 27 Mar. 2023, 2023/3/27:

  • Fix issues when --persistent_data_loader_workers is specified.

    • The batch members of the bucket are not shuffled.
    • --caption_dropout_every_n_epochs does not work.
    • These issues occurred because the epoch transition was not recognized correctly. Thanks to u-haru for reporting the issue.
  • Fix an issue that images are loaded twice in Windows environment.

  • Add Min-SNR Weighting strategy. Details are in #308. Thank you to AI-Casanova for this great work!

    • Add --min_snr_gamma option to training scripts, 5 is recommended by paper.
  • Add tag warmup. Details are in #322. Thanks to u-haru!

    • Add token_warmup_min and token_warmup_step to dataset settings.
    • Gradually increase the number of tokens from token_warmup_min to token_warmup_step.
    • For example, if token_warmup_min is 3 and token_warmup_step is 10, the first step will use the first 3 tokens, and the 10th step will use all tokens.
  • Fix a bug in resize_lora.py. Thanks to mgz-dev! #328

  • Add --debug_dataset option to step to the next step with S key and to the next epoch with E key.

  • Fix other bugs.

  • --persistent_data_loader_workers を指定した時の各種不具合を修正しました。

    • --caption_dropout_every_n_epochs が効かない。
    • バケットのバッチメンバーがシャッフルされない。
    • エポックの遷移が正しく認識されないために発生していました。ご指摘いただいたu-haru氏に感謝します。
  • Windows環境で画像が二重に読み込まれる不具合を修正しました。

  • Min-SNR Weighting strategyを追加しました。 詳細は #308 をご参照ください。AI-Casanova氏の素晴らしい貢献に感謝します。

    • --min_snr_gamma オプションを学習スクリプトに追加しました。論文では5が推奨されています。
  • タグのウォームアップを追加しました。詳細は #322 をご参照ください。u-haru氏に感謝します。

    • データセット設定に token_warmup_mintoken_warmup_step を追加しました。
    • token_warmup_min で指定した数のトークン(カンマ区切りの文字列)から、token_warmup_step で指定したステップまで、段階的にトークンを増やしていきます。
    • たとえば token_warmup_min3 を、token_warmup_step10 を指定すると、最初のステップでは最初から3個のトークンが使われ、10ステップ目では全てのトークンが使われます。
  • resize_lora.py の不具合を修正しました。mgz-dev氏に感謝します。#328

  • --debug_dataset オプションで、Sキーで次のステップへ、Eキーで次のエポックへ進めるようにしました。

  • その他の不具合を修正しました。

Updates at 21 Mar. 2023, 2023/3/21:

  • Add --vae_batch_size for faster latents caching to each training script. This batches VAE calls.
    • Please start with2 or 4 depending on the size of VRAM.
  • Fix a number of training steps with --gradient_accumulation_steps and --max_train_epochs. Thanks to tsukimiya!
  • Extract parser setup to external scripts. Thanks to robertsmieja!
  • Fix an issue without .npz and with --full_path in training.
  • Support extensions with upper cases for images for not Windows environment.
  • Fix resize_lora.py to work with LoRA with dynamic rank (including conv_dim != network_dim). Thanks to toshiaki!
  • latentsのキャッシュを高速化する--vae_batch_size オプションを各学習スクリプトに追加しました。VAE呼び出しをバッチ化します。
    -VRAMサイズに応じて、24 程度から試してください。
  • --gradient_accumulation_steps--max_train_epochs を指定した時、当該のepochで学習が止まらない不具合を修正しました。tsukimiya氏に感謝します。
  • 外部のスクリプト用に引数parserの構築が関数化されました。robertsmieja氏に感謝します。
  • 学習時、--full_path 指定時に .npz が存在しない場合の不具合を解消しました。
  • Windows以外の環境向けに、画像ファイルの大文字の拡張子をサポートしました。
  • resize_lora.py を dynamic rank (rankが各LoRAモジュールで異なる場合、conv_dimnetwork_dim と異なる場合も含む)の時に正しく動作しない不具合を修正しました。toshiaki氏に感謝します。

Version 0.5.2

21 Mar 13:02
4323531

Choose a tag to compare

Updates at 19 Mar. 2023, 2023/3/19:

  • Add a function to load training config with .toml to each training script. Thanks to Linaqruf for this great contribution!

    • Specify .toml file with --config_file. .toml file has key=value entries. Keys are same as command line options. See #241 for details.
    • All sub-sections are combined to a single dictionary (the section names are ignored.)
    • Omitted arguments are the default values for command line arguments.
    • Command line args override the arguments in .toml.
    • With --output_config option, you can output current command line options to the .toml specified with--config_file. Please use as a template.
  • Add --lr_scheduler_type and --lr_scheduler_args arguments for custom LR scheduler to each training script. Thanks to Isotr0py! #271

    • Same as the optimizer.
  • Add sample image generation with weight and no length limit. Thanks to mio2333! #288

    • ( ), (xxxx:1.2) and [ ] can be used.
  • Fix exception on training model in diffusers format with train_network.py Thanks to orenwang! #290

  • 各学習スクリプトでコマンドライン引数の代わりに.toml ファイルで引数を指定できるようになりました。Linaqruf氏の多大な貢献に感謝します。

    • --config_file.toml ファイルを指定してください。ファイルは key=value 形式の行で指定し、key はコマンドラインオプションと同じです。詳細は #241 をご覧ください。
    • ファイル内のサブセクションはすべて無視されます。
    • 省略した引数はコマンドライン引数のデフォルト値になります。
    • コマンドライン引数で .toml の設定を上書きできます。
    • --output_config オプションを指定すると、現在のコマンドライン引数を--config_file オプションで指定した .toml ファイルに出力します。ひな形としてご利用ください。
  • 任意のスケジューラを使うための --lr_scheduler_type--lr_scheduler_args オプションを各学習スクリプトに追加しました。Isotr0py氏に感謝します。 #271

    • 任意のオプティマイザ指定と同じ形式です。
  • 学習中のサンプル画像出力でプロンプトの重みづけができるようになりました。また長さ制限も緩和されています。mio2333氏に感謝します。 #288

    • ( )(xxxx:1.2)[ ] が使えます。
  • train_network.py でローカルのDiffusersモデルを指定した時のエラーを修正しました。orenwang氏に感謝します。 #290

Updates at 11 Mar. 2023, 2023/3/11:

  • Fix svd_merge_lora.py causes an error about the device.
  • svd_merge_lora.py でデバイス関連のエラーが発生する不具合を修正しました。

Version 0.5.1

10 Mar 22:58
b80431d

Choose a tag to compare

Updates at 10 Mar. 2023, 2023/3/10: release v0.5.1

  • Fix to LoRA modules in the model are same to the previous (before 0.5.0) if Conv2d-3x3 is disabled (no conv_dim arg, default).

    • Conv2D with kernel size 1x1 in ResNet modules were accidentally included in v0.5.0.
    • Trained models with v0.5.0 will work with Web UI's built-in LoRA and Additional Networks extension.
  • Fix an issue that dim (rank) of LoRA module is limited to the in/out dimensions of the target Linear/Conv2d (in case of the dim > 320).

  • resize_lora.py now have a feature to dynamic resizing which means each LoRA module can have different ranks (dims). Thanks to mgz-dev for this great work!

    • The appropriate rank is selected based on the complexity of each module with an algorithm specified in the command line arguments. For details: #243
  • Multiple GPUs training is finally supported in train_network.py. Thanks to ddPn08 to solve this long running issue!

  • Dataset with fine-tuning method (with metadata json) now works without images if .npz files exist. Thanks to rvhfxb!

  • train_network.py can work if the current directory is not the directory where the script is in. Thanks to mio2333!

  • Fix extract_lora_from_models.py and svd_merge_lora.py doesn't work with higher rank (>320).

  • LoRAのConv2d-3x3拡張を行わない場合(conv_dim を指定しない場合)、以前(v0.5.0)と同じ構成になるよう修正しました。

    • ResNetのカーネルサイズ1x1のConv2dが誤って対象になっていました。
    • ただv0.5.0で学習したモデルは Additional Networks 拡張、およびWeb UIのLoRA機能で問題なく使えると思われます。
  • LoRAモジュールの dim (rank) が、対象モジュールの次元数以下に制限される不具合を修正しました(320より大きい dim を指定した場合)。

  • resize_lora.pydynamic resizing (リサイズ後の各LoRAモジュールが異なるrank (dim) を持てる機能)を追加しました。mgz-dev 氏の貢献に感謝します。

    • 適切なランクがコマンドライン引数で指定したアルゴリズムにより自動的に選択されます。詳細はこちらをご覧ください: #243
  • train_network.py でマルチGPU学習をサポートしました。長年の懸案を解決された ddPn08 氏に感謝します。

  • fine-tuning方式のデータセット(メタデータ.jsonファイルを使うデータセット)で .npz が存在するときには画像がなくても動作するようになりました。rvhfxb 氏に感謝します。

  • 他のディレクトリから train_network.py を呼び出しても動作するよう変更しました。 mio2333 氏に感謝します。

  • extract_lora_from_models.py および svd_merge_lora.py が320より大きいrankを指定すると動かない不具合を修正しました。

Updates at 9 Mar. 2023, 2023/3/9: release v0.5.0

  • There may be problems due to major changes. If you cannot revert back to the previous version when problems occur, please do not update for a while.
  • Minimum metadata (module name, dim, alpha and network_args) is recorded even with --no_metadata, issue #254
  • train_network.py supports LoRA for Conv2d-3x3 (extended to conv2d with a kernel size not 1x1).
    • Same as a current version of LoCon. Thank you very much KohakuBlueleaf for your help!
      • LoCon will be enhanced in the future. Compatibility for future versions is not guaranteed.
    • Specify --network_args option like: --network_args "conv_dim=4" "conv_alpha=1"
    • Additional Networks extension version 0.5.0 or later is required to use 'LoRA for Conv2d-3x3' in Stable Diffusion web UI.
    • Stable Diffusion web UI built-in LoRA does not support 'LoRA for Conv2d-3x3' now. Consider carefully whether or not to use it.
  • Merging/extracting scripts also support LoRA for Conv2d-3x3.
  • Free CUDA memory after sample generation to reduce VRAM usage, issue #260
  • Empty caption doesn't cause error now, issue #258
  • Fix sample generation is crashing in Textual Inversion training when using templates, or if height/width is not divisible by 8.
  • Update documents (Japanese only).

Version 0.4.5

07 Mar 10:30

Choose a tag to compare

Updates at 2 Mar. 2023, 2023/3/2:

  • Dependencies are updated, Please upgrade the repo.

  • Add detail dataset config feature by extra config file. Thanks to fur0ut0 for this great contribution!

    • Documentation is here (only in Japanese currently.)
    • Specify .toml file with --dataset_config option.
    • The previous options for dataset can be used as is.
    • There might be a bug due to the large scale of update, please report any problems if you find.
  • Add feature to generate sample images in the middle of training for each training scripts.

    • --sample_every_n_steps and --sample_every_n_epochs options: frequency to generate.
    • --sample_prompts option: the file contains prompts (each line generates one image.)
      • The prompt is subset of gen_img_diffusers.py. The prompt options w, h, d, l, s, n are supported.
    • --sample_sampler option: sampler (scheduler) for generating, such as ddim or k_euler. See help for useable samplers.
  • Add --tokenizer_cache_dir to each training and generation scripts to cache Tokenizer locally from Diffusers.

    • Scripts will support offline training/generation after caching.
  • Support letents upscaling for highres. fix, and VAE batch size in gen_img_diffusers.py (no documentation yet.)

  • ライブラリを更新しました。アップグレードに従って更新してください。

  • 設定ファイルによるデータセット定義機能を追加しました。素晴らしいPRを提供していただいた fur0ut0 氏に感謝します。

    • ドキュメントはこちら
    • --dataset_config オプションで .toml ファイルを指定してください。
    • 今までのオプションはそのまま使えます。
    • 大規模なアップデートのため、もし不具合がありましたらご報告ください。
  • 学習の途中でサンプル画像を生成する機能を各学習スクリプトに追加しました。

    • --sample_every_n_steps--sample_every_n_epochs オプション:生成頻度を指定
    • --sample_prompts オプション:プロンプトを記述したファイルを指定(1行ごとに1枚の画像を生成)
      • プロンプトには gen_img_diffusers.py のプロンプトオプションの一部、 w, h, d, l, s, n が使えます。
    • --sample_sampler オプション:ddim や k_euler などの sampler (scheduler) を指定します。使用できる sampler についてはヘルプをご覧ください。
  • --tokenizer_cache_dir オプションを各学習スクリプトおよび生成スクリプトに追加しました。Diffusers から Tokenizer を取得してきてろーかるに保存します。

    • 一度キャッシュしておくことでオフライン学習、生成ができるかもしれません。
  • gen_img_diffusers.py で highres. fix での letents upscaling と VAE のバッチサイズ指定に対応しました。

Version 0.4.4

02 Mar 12:35
f0ae7ee

Choose a tag to compare

Updates at 23 Feb. 2023, 2023/2/23:

  • Fix instability training issue in train_network.py.
    • fp16 training is probably not affected by this issue.
    • Training with float for SD2.x models will work now. Also training with bf16 might be improved.
    • This issue seems to have occurred in PR#190.
  • Add some metadata to LoRA model. Thanks to space-nuko!
  • Raise an error if optimizer options conflict (e.g. --optimizer_type and --use_8bit_adam.)
  • Support ControlNet in gen_img_diffusers.py (no documentation yet.)
  • train_network.py で学習が不安定になる不具合を修正しました。
    • fp16 精度での学習には恐らくこの問題は影響しません。
    • float 精度での SD2.x モデルの学習が正しく動作するようになりました。また bf16 精度の学習も改善する可能性があります。
    • この問題は PR#190 から起きていたようです。
  • いくつかのメタデータを LoRA モデルに追加しました。 space-nuko 氏に感謝します。
  • オプティマイザ関係のオプションが矛盾していた場合、エラーとするように修正しました(例: --optimizer_type--use_8bit_adam)。
  • gen_img_diffusers.py で ControlNet をサポートしました(ドキュメントはのちほど追加します)。

Updates at 22 Feb. 2023, 2023/2/22:

  • Refactor optmizer options. Thanks to mgz-dev!
    • Add --optimizer_type option for each training script. Please see help. Japanese documentation is here.
    • --use_8bit_adam and --use_lion_optimizer options also work, but override above option.
  • Add SGDNesterov and its 8bit.
  • Add D-Adaptation optimizer. Thanks to BootsofLagrangian and all!
    • Please install D-Adaptation optimizer with pip install dadaptation (it is not in requirements.txt currently.)
    • Please see #181 for details.
  • Add AdaFactor optimizer. Thanks to Toshiaki!
  • Extra lr scheduler settings (num_cycles etc.) are working in training scripts other than train_network.py.
  • Add --max_grad_norm option for each training script for gradient clipping. 0.0 disables clipping.
  • Symbolic link can be loaded in each training script. Thanks to TkskKurumi!
  • オプティマイザ関連のオプションを見直しました。mgz-dev氏に感謝します。
    • --optimizer_type を各学習スクリプトに追加しました。ドキュメントはこちら
    • --use_8bit_adam--use_lion_optimizer のオプションは依然として動作しますがoptimizer_typeを上書きしますのでご注意ください。
  • SGDNesterov オプティマイザおよびその8bit版を追加しました。
  • D-Adaptation オプティマイザを追加しました。BootsofLagrangian 氏および諸氏に感謝します。
    • pip install dadaptation コマンドで別途インストールが必要です(現時点ではrequirements.txtに含まれておりません)。
    • こちらのissueもあわせてご覧ください。 #181
  • AdaFactor オプティマイザを追加しました。Toshiaki氏に感謝します。
  • 追加のスケジューラ設定(num_cycles等)が train_network.py 以外の学習スクリプトでも使えるようになりました。
  • 勾配クリップ時の最大normを指定する --max_grad_norm オプションを追加しました。0.0を指定するとクリップしなくなります。
  • 各学習スクリプトでシンボリックリンクが読み込めるようになりました。TkskKurumi氏に感謝します。

Version 0.4.3

22 Feb 12:11
08ae46b

Choose a tag to compare

Updates at 19 Feb. 2023, 2023/2/19:

  • Add --use_lion_optimizer to each training script to use Lion optimizer.

    • Please install Lion optimizer with pip install lion-pytorch (it is not in requirements.txt currently.)
  • Add --lowram option to train_network.py. Load models to VRAM instead of VRAM (for machines which have bigger VRAM than RAM such as Colab and Kaggle). Thanks to Isotr0py!

    • Default behavior (without lowram) has reverted to the same as before 14 Feb.
  • Fixed git commit hash to be set correctly regardless of the working directory. Thanks to vladmandic!

  • --use_lion_optimizer オプションを各学習スクリプトに追加しました。 Lion optimizer を使用できます。

    • あらかじめ pip install lion-pytorch でインストールしてください(現在は requirements.txt に含まれていません)。
  • --lowram オプションを train_network.py に追加しました。モデルをRAMではなくVRAMに読み込みます(ColabやKaggleなど、VRAMがRAMに比べて多い環境で有効です)。 Isotr0py 氏に感謝します。

    • lowram オプションなしのデフォルト動作は2/14より前と同じに戻しました。
  • git commit hash を現在のフォルダ位置に関わらず正しく取得するように修正しました。vladmandic 氏に感謝します。

Updates at 16 Feb. 2023, 2023/2/16:

  • Noise offset is recorded to the metadata. Thanks to space-nuko!
  • Show the moving average loss to prevent loss jumping in train_network.py and train_db.py. Thanks to shirayu!
  • Noise offsetがメタデータに記録されるようになりました。space-nuko氏に感謝します。
  • train_network.pytrain_db.pyで学習中に表示されるlossの値が移動平均になりました。epochの先頭で表示されるlossが大きく変動する事象を解決します。shirayu氏に感謝します。
  • 14 Feb. 2023, 2023/2/14:
    • Add support with multi-gpu trainining for train_network.py. Thanks to Isotr0py!
    • Add --verbose option for resize_lora.py. For details, see this PR. Thanks to mgz-dev!
    • Git commit hash is added to the metadata for LoRA. Thanks to space-nuko!
    • Add --noise_offset option for each training scripts.
    • train_network.pyでマルチGPU学習をサポートしました。Isotr0py氏に感謝します。
    • --verboseオプションを resize_lora.py に追加しました。表示される情報の詳細は こちらのPR をご参照ください。mgz-dev氏に感謝します。
    • LoRAのメタデータにgitのcommit hashを追加しました。space-nuko氏に感謝します。
    • --noise_offset オプションを各学習スクリプトに追加しました。

Updates at 11 Feb. 2023, 2023/2/11:

  • lora_interrogator.py is added in networks folder. See python networks\lora_interrogator.py -h for usage.

    • For LoRAs where the activation word is unknown, this script compares the output of Text Encoder after applying LoRA to that of unapplied to find out which token is affected by LoRA. Hopefully you can figure out the activation word. LoRA trained with captions does not seem to be able to interrogate.
    • Batch size can be large (like 64 or 128).
  • train_textual_inversion.py now supports multiple init words.

  • Following feature is reverted to be the same as before. Sorry for confusion:

    Now the number of data in each batch is limited to the number of actual images (not duplicated). Because a certain bucket may contain smaller number of actual images, so the batch may contain same (duplicated) images.

  • lora_interrogator.pynetworkフォルダに追加しました。使用法は python networks\lora_interrogator.py -h でご確認ください。

    • このスクリプトは、起動promptがわからないLoRAについて、LoRA適用前後のText Encoderの出力を比較することで、どのtokenの出力が変化しているかを調べます。運が良ければ起動用の単語が分かります。キャプション付きで学習されたLoRAは影響が広範囲に及ぶため、調査は難しいようです。
    • バッチサイズはわりと大きくできます(64や128など)。
  • train_textual_inversion.py で複数のinit_word指定が可能になりました。

  • 次の機能を削除し元に戻しました。混乱を招き申し訳ありません。

    これらのオプションによりbucketが細分化され、ひとつのバッチ内に同一画像が重複して存在することが増えたため、バッチサイズをそのbucketの画像種類数までに制限する機能を追加しました。

Updates at 10 Feb. 2023, 2023/2/10:

  • Updated requirements.txt to prevent upgrading with pip taking a long time or failure to upgrade.
  • resize_lora.py keeps the metadata of the model. dimension is resized from ... is added to the top of ss_training_comment.
  • merge_lora.py supports models with different alphas. If there is a problem, old version is merge_lora_old.py.
  • svd_merge_lora.py is added. This script merges LoRA models with any rank (dim) and alpha, and approximate a new LoRA with svd for a specified rank (dim).
  • Note: merging scripts erase the metadata currently.
  • resize_images_to_resolution.py supports multibyte characters in filenames.
  • pipでの更新が長時間掛かったり、更新に失敗したりするのを防ぐため、requirements.txtを更新しました。
  • resize_lora.pyがメタデータを保持するようになりました。 dimension is resized from ... という文字列が ss_training_comment の先頭に追加されます。
  • merge_lora.pyがalphaが異なるモデルをサポートしました。 何か問題がありましたら旧バージョン merge_lora_old.py をお使いください。
  • svd_merge_lora.py を追加しました。 複数の任意のdim (rank)、alphaのLoRAモデルをマージし、svdで任意dim(rank)のLoRAで近似します。
  • 注:マージ系のスクリプトは現時点ではメタデータを消去しますのでご注意ください。
  • resize_images_to_resolution.pyが日本語ファイル名をサポートしました。

Updates at 9 Feb. 2023, 2023/2/9:

  • Caption dropout is supported in train_db.py, fine_tune.py and train_network.py. Thanks to forestsource!
    • --caption_dropout_rate option specifies the dropout rate for captions (0~1.0, 0.1 means 10% chance for dropout). If dropout occurs, the image is trained with the empty caption. Default is 0 (no dropout).
    • --caption_dropout_every_n_epochs option specifies how many epochs to drop captions. If 3 is specified, in epoch 3, 6, 9 ..., images are trained with all captions empty. Default is None (no dropout).
    • --caption_tag_dropout_rate option specified the dropout rate for tags (comma separated tokens) (0~1.0, 0.1 means 10% chance for dropout). If dropout occurs, the tag is removed from the caption. If --keep_tokens option is set, these tokens (tags) are not dropped. Default is 0 (no droupout).
    • The bulk image downsampling script is added. Documentation is here (in Jpanaese). Thanks to bmaltais!
    • Typo check is added. Thanks to shirayu!
  • キャプションのドロップアウトをtrain_db.pyfine_tune.pytrain_network.pyの各スクリプトに追加しました。forestsource氏に感謝します。
    • --caption_dropout_rateオプションでキャプションのドロップアウト率を指定します(0~1.0、 0.1を指定すると10%の確率でドロップアウト)。ドロップアウトされた場合、画像は空のキャプションで学習されます。デフォルトは 0 (ドロップアウトなし)です。
    • --caption_dropout_every_n_epochs オプションで何エポックごとにキャプションを完全にドロップアウトするか指定します。たとえば3を指定すると、エポック3、6、9……で、すべての画像がキャプションなしで学習されます。デフォルトは None (ドロップアウトなし)です。
    • --caption_tag_dropout_rate オプションで各タグ(カンマ区切りの各部分)のドロップアウト率を指定します(0~1.0、 0.1を指定すると10%の確率でドロップアウト)。ドロップアウトが起きるとそのタグはそのときだけキャプションから取り除かれて学習されます。--keep_tokens オプションを指定していると、シャッフルされない部分のタグはドロップアウトされません。デフォルトは 0 (ドロップアウトなし)です。
    • 画像の一括縮小スクリプトを追加しました。ドキュメントは こちら です。bmaltais氏に感謝します。
    • 誤字チェッカが追加されました。shirayu氏に感謝します。

Updates at 6 Feb. 2023, 2023/2/6:

  • --bucket_reso_steps and --bucket_no_upscale options are added to training scripts (fine tuning, DreamBooth, LoRA and Textual Inversion) and prepare_buckets_latents.py.

  • --bucket_reso_steps takes the steps for buckets in aspect ratio bucketing. Default is 64, same as before.

    • Any value greater than or equal to 1 can be specified; 64 is highly recommended and a value divisible by 8 is recommended.
    • If less than 64 is specified, padding will occur within U-Net. The result is unknown.
    • If you specify a value that is not divisible by 8, it will be truncated to divisible by 8 inside VAE, because the size of the latent is 1/8 of the image size.
  • If --bucket_no_upscale option is specified, images smaller than the bucket size will be processed without upscaling.

    • Internally, a bucket smaller than the image size is created (for example, if the image is 300x300 and bucket_reso_steps=64, the bucket is 256x256). The image will be trimmed.
    • Implementation of #130.
    • Images with an area larger than the maximum size specified by --resolution are downsampled to the max bucket size.
  • Now the number of data in each batch is limited to the number of actual images (not duplicated). Because a certain bucket may contain smaller number of actual images, so the batch may contain same (duplicated) images.

  • --random_crop now also works with buckets enabled.

    • Instead of always cropping the center of the image, the image is shifted left, right, up, and down to be used as the training data. This is expected to train to the edges of the image.
    • Implementation of discussion #34.
  • --bucket_reso_stepsおよび--bucket_no_upscaleオプションを、学習スクリプトおよびprepare_buckets_latents.pyに追加しました。

  • --bucket_reso_stepsオプションでは、bucketの解像度の単位を指定できます。デフォルトは64で、今までと同じ動作です。

    • 1以上の任意の値を指定できます。基本的には64を推奨します。64以外の値では、8で割り切れる値を推奨します。
    • 64未満を指定するとU-Netの内部でpaddingが発生します。どのような結果になるかは未知数です。
    • 8で割り切れない値を指定すると余りはVAE内部で切り捨てられます。
  • --bucket_no_upscaleオプションを指定すると、bucketサイズよりも小さい画像は拡大せずそのまま処理します。

    • 内部的には画像サイズ以下のサイズのbucketを作成します(たとえば画像が300x300でbucket_reso_steps=64の場合、256x256のbucket)。余りは都度trimmingされます。
    • #130 を実装したものです。
    • --resolutionで指定した最大サイズよりも面積が大きい画像は、最大サイズと同じ面積になるようアスペクト比を維持したまま縮小され、そのサイズを元にbucketが作られます。
  • これらのオプションによりbucketが細分化され、ひとつのバッチ内に同一画像が重複して存在することが増えたため、バッチサイズを``そのbucket...

Read more

Version 0.4.2

06 Feb 11:54
ae33d72

Choose a tag to compare

Updates at 4 Feb. 2023, 2023/2/4

  • --persistent_data_loader_workers option is added to fine_tune.py, train_db.py and train_network.py. This option may significantly reduce the waiting time between epochs. Thanks to hitomi!
  • --debug_dataset option is now working on non-Windows environment. Thanks to tsukimiya!
  • networks/resize_lora.py script is added. This can approximate the higher-rank (dim) LoRA model by a lower-rank LoRA model, e.g. 128 by 4. Thanks to mgz-dev!
    • --help option shows usage.
    • Currently the metadata is not copied. This will be fixed in the near future.
  • --persistent_data_loader_workersオプションが fine_tune.pytrain_db.pytrain_network.pyの各スクリプトに追加されました。このオプションを指定するとエポック間の待ち時間が大幅に短縮される可能性があります。hitomi氏に感謝します。
  • --debug_datasetオプションがWindows環境以外でも動くようになりました。tsukimiya氏に感謝します。
  • networks/resize_lora.pyスクリプトを追加しました。高rankのLoRAモデルを低rankのLoRAモデルで近似します(つまり128 rank (dim)のLoRAに似た、4 rank (dim)のLoRAを作ることができます)。mgz-dev氏に感謝します。
    • 使い方は--helpオプションを指定して参照してください。
    • 現時点ではメタデータはコピーされません。近日中に対応予定です。

Updates at 3 Feb. 2023, 2023/2/3

  • Update finetune preprocessing scripts.

    • .bmp and .jpeg are supported. Thanks to breakcore2 and p1atdev!
    • The default weights of tag_images_by_wd14_tagger.py is now SmilingWolf/wd-v1-4-convnext-tagger-v2. You can specify another model id from SmilingWolf by --repo_id option. Thanks to SmilingWolf for the great work.
      • To change the weight, remove wd14_tagger_model folder, and run the script again.
    • --max_data_loader_n_workers option is added to each script. This option uses the DataLoader for data loading to speed up loading, 20%~30% faster.
      • Please specify 2 or 4, depends on the number of CPU cores.
    • --recursive option is added to merge_dd_tags_to_metadata.py and merge_captions_to_metadata.py, only works with --full_path.
    • make_captions_by_git.py is added. It uses GIT microsoft/git-large-textcaps for captioning.
      • requirements.txt is updated. If you use this script, please update the libraries.
      • Usage is almost the same as make_captions.py, but batch size should be smaller.
      • --remove_words option removes as much text as possible (such as the word "XXXX" on it).
    • --skip_existing option is added to prepare_buckets_latents.py. Images with existing npz files are ignored by this option.
    • clean_captions_and_tags.py is updated to remove duplicated or conflicting tags, e.g. shirt is removed when white shirt exists. if black hair is with red hair, both are removed.
  • Tag frequency is added to the metadata in train_network.py. Thanks to space-nuko!

    • All tags and number of occurrences of the tag are recorded. If you do not want it, disable metadata storing with --no_metadata option.
  • fine tuning用の前処理スクリプト群を更新しました。

    • 拡張子 .bmp.jpeg をサポートしました。breakcore2氏およびp1atdev氏に感謝します。
    • tag_images_by_wd14_tagger.py のデフォルトの重みを SmilingWolf/wd-v1-4-convnext-tagger-v2 に更新しました。他の SmilingWolf 氏の重みも --repo_id オプションで指定可能です。SmilingWolf氏に感謝します。
      • 重みを変更するときには wd14_tagger_model フォルダを削除してからスクリプトを再実行してください。
    • --max_data_loader_n_workers オプションが各スクリプトに追加されました。DataLoaderを用いることで読み込み処理を並列化し、処理を20~30%程度高速化します。
      • CPUのコア数に応じて2~4程度の値を指定してください。
    • --recursive オプションを merge_dd_tags_to_metadata.pymerge_captions_to_metadata.py に追加しました。--full_path を指定したときのみ使用可能です。
    • make_captions_by_git.py を追加しました。GIT microsoft/git-large-textcaps を用いてキャプションニングを行います。
      • requirements.txt が更新されていますので、ライブラリをアップデートしてください。
      • 使用法は make_captions.pyとほぼ同じですがバッチサイズは小さめにしてください。
      • --remove_words オプションを指定するとテキスト読み取りを可能な限り削除します(the word "XXXX" on itのようなもの)。
    • --skip_existingprepare_buckets_latents.py に追加しました。すでにnpzファイルがある画像の処理をスキップします。
    • clean_captions_and_tags.pyを重複タグや矛盾するタグを削除するよう機能追加しました。例:white shirt タグがある場合、 shirt タグは削除されます。またblack hairred hairの両方がある場合、両方とも削除されます。
  • train_network.pyで使用されているタグと回数をメタデータに記録するようになりました。space-nuko氏に感謝します。

    • すべてのタグと回数がメタデータに記録されます 望まない場合には--no_metadata optionオプションでメタデータの記録を停止してください。

Version 0.4.1

03 Feb 13:05
4cabb37

Choose a tag to compare

Updates at 29 Jan. 2023, 2023/1/29

  • Add --lr_scheduler_num_cycles and --lr_scheduler_power options for train_network.py for cosine_with_restarts and polynomial learning rate schedulers. Thanks to mgz-dev!
  • Fixed U-Net sample_size parameter to 64 when converting from SD to Diffusers format, in convert_diffusers20_original_sd.py
  • --lr_scheduler_num_cycles--lr_scheduler_power オプションを train_network.py に追加しました。前者は cosine_with_restarts、後者は polynomial の学習率スケジューラに有効です。mgz-dev氏に感謝します。
  • convert_diffusers20_original_sd.py で SD 形式から Diffusers に変換するときの U-Net の sample_size パラメータを 64 に修正しました。

Updates at 26 Jan. 2023, 2023/1/26

  • Add Textual Inversion training. Documentation is here (in Japanese.)
  • Textual Inversionの学習をサポートしました。ドキュメントはこちら

Updates at 24 Jan. 2023, 2023/1/24

  • Change the default save format to .safetensors for train_network.py.
  • Add --save_n_epoch_ratio option to specify how often to save. Thanks to forestsource!
    • For example, if 5 is specified, 5 (or 6) files will be saved in training.
  • Add feature to pre-calculate hash to reduce loading time in the extension. Thanks to space-nuko!
  • Add bucketing metadata. Thanks to space-nuko!
  • Fix an error with bf16 model in gen_img_diffusers.py.
  • train_network.py のモデル保存形式のデフォルトを .safetensors に変更しました。
  • モデルを保存する頻度を指定する --save_n_epoch_ratio オプションが追加されました。forestsource氏に感謝します。
    • たとえば 5 を指定すると、学習終了までに合計で5個(または6個)のファイルが保存されます。
  • 拡張でモデル読み込み時間を短縮するためのハッシュ事前計算の機能を追加しました。space-nuko氏に感謝します。
  • メタデータにbucket情報が追加されました。space-nuko氏に感謝します。
  • gen_img_diffusers.py でbf16形式のモデルを読み込んだときのエラーを修正しました。

Version 0.4.0

22 Jan 13:05
0ca0642

Choose a tag to compare

  • Add --network_alpha option to specify alpha value to prevent underflows for stable training. Thanks to CCRcmcpe!

    • Details of the issue are described in kohya-ss/sd-webui-additional-networks#49 .
    • The default value is 1, scale 1 / rank (or dimension). Set same value as network_dim for same behavior to old version.
    • LoRA with a large dimension (rank) seems to require a higher learning rate with alpha=1 (e.g. 1e-3 for 128-dim, still investigating). 
  • Add logging for the learning rate for U-Net and Text Encoder independently, and for running average epoch loss. Thanks to mgz-dev!

  • Add more metadata such as dataset/reg image dirs, session ID, output name etc... See #77 for details. Thanks to space-nuko!

    • Now the metadata includes the folder name (the basename of the folder contains image files, not fullpath). If you do not want it, disable metadata storing with --no_metadata option.
  • Add --training_comment option. You can specify an arbitrary string and refer to it by the extension.

  • アンダーフローを防ぎ安定して学習するための alpha 値を指定する、--network_alpha オプションを追加しました。CCRcmcpe 氏に感謝します。

    • 問題の詳細はこちらをご覧ください: kohya-ss/sd-webui-additional-networks#49
    • デフォルト値は 1 で、LoRAの計算結果を 1 / rank (dimension・次元数) 倍します(つまり小さくなります。これにより同じ効果を出すために必要なLoRAの重みの変化が大きくなるため、アンダーフローが避けられるようになります)。network_dim と同じ値を指定すると旧バージョンと同じ動作になります。
    • alpha=1の場合、次元数(rank)の多いLoRAモジュールでは学習率を高めにしたほうが良いようです(128次元で1e-3など)。
  • U-Net と Text Encoder のそれぞれの学習率、エポックの平均lossをログに記録するようになりました。mgz-dev 氏に感謝します。

  • 画像ディレクトリ、セッションID、出力名などいくつかの項目がメタデータに追加されました(詳細は #77 を参照)。space-nuko氏に感謝します。

    • メタデータにフォルダ名が含まれるようになりました(画像を含むフォルダの名前のみで、フルパスではありません)。 もし望まない場合には --no_metadata オプションでメタデータの記録を止めてください。
  • --training_comment オプションを追加しました。任意の文字列を指定でき、Web UI拡張から参照できます。