
LORAファイルをメタ情報とLORAウェイトの定量分析について検査します。
safetensorsのみがサポートされています(すべてのLORAファイルをサポートしたい)これは進行中の作業であり、生産用の使用を目的としていないことに注意してください。注記
GUI表現のために新しいWebインターフェイスLORAインスペクターを使用することを検討してください。
このレポをクローンするか、Pythonスクリプトファイルをダウンロードします。
依存関係が必要です:
torch
safetensors
tqdm
次のいずれかをインストールできます。
venv )を使用します。推奨pip install safetensors tqdm (Pytorchのインストール方法に関する手順については、入手を参照してください) $ python lora-inspector.py --help
usage: lora-inspector.py [-h] [-s] [-w] [-t] [-d] lora_file_or_dir
positional arguments:
lora_file_or_dir Directory containing the lora files
options:
-h, --help show this help message and exit
-s, --save_meta Should we save the metadata to a file ?
-w, --weights Show the average magnitude and strength of the weights
-t, --tags Show the most common tags in the training set
-d, --dataset Show the dataset metadata including directory names and number of imagesディレクトリまたはファイルを追加できます。
$ python lora-inspector.py /mnt/900/training/sets/landscape-2023-11-06-200718-e4d7120b -w
/mnt/900/training/sets/landscape-2023-11-06-200718-e4d7120b/landscape-2023-11-06-200718-e4d7120b-000015.safetensors
Date: 2023-11-06T20:16:34 Title: landscape
License: CreativeML Open RAIL-M Author: rockerBOO
Description: High quality landscape photos
Resolution: 512x512 Architecture: stable-diffusion-v1/lora
Network Dim/Rank: 16.0 Alpha: 8.0 Dropout: 0.3 dtype: torch.float32
Module: networks.lora : { ' block_dims ' : ' 4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 ' , ' block_alphas ' : ' 16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ' , ' block_dropout ' : ' 0.01, 0.010620912260804992, 0.01248099020159499, 0.015572268683063176, 0.01988151037617019, 0.02539026244641935, 0.032074935571726845, 0.03990690495552037, 0.04885263290251277, 0.058873812432261884, 0.0699275313155418, 0.08196645583109653, 0.09493903345590124, 0.10878971362098, 0.12345918558747097, 0.13888463242431537, 0.155, 0.17173627983648962, 0.18902180461412393, 0.20678255506208312, 0.22494247692026895, 0.2434238066153228, 0.26214740425618505, 0.2810330925232585 ' , ' dropout ' : 0.3}
Learning Rate (LR): 2e-06 UNet LR: 1.0 TE LR: 1.0
Optimizer: prodigyopt.prodigy.Prodigy(weight_decay=0.1,betas=(0.9, 0.9999),d_coef=1.5,use_bias_correction=True)
Scheduler: cosine Warmup steps: 0
Epoch: 15 Batches per epoch: 57 Gradient accumulation steps: 24
Train images: 57 Regularization images: 0
Noise offset: 0.05 Adaptive noise scale: 0.01 IP noise gamma: 0.1 Multires noise discount: 0.3
Min SNR gamma: 5.0 Zero terminal SNR: True Debiased Estimation: True
UNet weight average magnitude: 0.7865518983141094
UNet weight average strength: 0.00995593195090544
No Text Encoder found in this LoRA
----------------------
/mnt/900/training/sets/landscape-2023-11-06-200718-e4d7120b/landscape-2023-11-06-200718-e4d7120b.safetensors
Date: 2023-11-06T20:27:12 Title: landscape
License: CreativeML Open RAIL-M Author: rockerBOO
Description: High quality landscape photos
Resolution: 512x512 Architecture: stable-diffusion-v1/lora
Network Dim/Rank: 16.0 Alpha: 8.0 Dropout: 0.3 dtype: torch.float32
Module: networks.lora : { ' block_dims ' : ' 4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 ' , ' block_alphas ' : ' 16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ' , ' block_dropout ' : ' 0.01, 0.010620912260804992, 0.01248099020159499, 0.015572268683063176, 0.01988151037617019, 0.02539026244641935, 0.032074935571726845, 0.03990690495552037, 0.04885263290251277, 0.058873812432261884, 0.0699275313155418, 0.08196645583109653, 0.09493903345590124, 0.10878971362098, 0.12345918558747097, 0.13888463242431537, 0.155, 0.17173627983648962, 0.18902180461412393, 0.20678255506208312, 0.22494247692026895, 0.2434238066153228, 0.26214740425618505, 0.2810330925232585 ' , ' dropout ' : 0.3}
Learning Rate (LR): 2e-06 UNet LR: 1.0 TE LR: 1.0
Optimizer: prodigyopt.prodigy.Prodigy(weight_decay=0.1,betas=(0.9, 0.9999),d_coef=1.5,use_bias_correction=True)
Scheduler: cosine Warmup steps: 0
Epoch: 30 Batches per epoch: 57 Gradient accumulation steps: 24
Train images: 57 Regularization images: 0
Noise offset: 0.05 Adaptive noise scale: 0.01 IP noise gamma: 0.1 Multires noise discount: 0.3
Min SNR gamma: 5.0 Zero terminal SNR: True Debiased Estimation: True
UNet weight average magnitude: 0.8033398082829257
UNet weight average strength: 0.010114916750103732
No Text Encoder found in this LoRA
----------------------$ python lora-inspector.py /mnt/900/lora/testing/landscape-2023-11-06-200718-e4d7120b.safetensors
/mnt/900/lora/testing/landscape-2023-11-06-200718-e4d7120b.safetensors
Date: 2023-11-06T20:27:12 Title: landscape
License: CreativeML Open RAIL-M Author: rockerBOO
Description: High quality landscape photos
Resolution: 512x512 Architecture: stable-diffusion-v1/lora
Network Dim/Rank: 16.0 Alpha: 8.0 Dropout: 0.3 dtype: torch.float32
Module: networks.lora : { ' block_dims ' : ' 4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 ' , ' block_alphas ' : ' 16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ' , ' block_dropout ' : ' 0.01, 0.010620912260804992, 0.01248099020159499, 0.015572268683063176, 0.01988151037617019, 0.02539026244641935, 0.032074935571726845, 0.03990690495552037, 0.04885263290251277, 0.058873812432261884, 0.0699275313155418, 0.08196645583109653, 0.09493903345590124, 0.10878971362098, 0.12345918558747097, 0.13888463242431537, 0.155, 0.17173627983648962, 0.18902180461412393, 0.20678255506208312, 0.22494247692026895, 0.2434238066153228, 0.26214740425618505, 0.2810330925232585 ' , ' dropout ' : 0.3}
Learning Rate (LR): 2e-06 UNet LR: 1.0 TE LR: 1.0
Optimizer: prodigyopt.prodigy.Prodigy(weight_decay=0.1,betas=(0.9, 0.9999),d_coef=1.5,use_bias_correction=True)
Scheduler: cosine Warmup steps: 0
Epoch: 30 Batches per epoch: 57 Gradient accumulation steps: 24
Train images: 57 Regularization images: 0
Noise offset: 0.05 Adaptive noise scale: 0.01 IP noise gamma: 0.1 Multires noise discount: 0.3
Min SNR gamma: 5.0 Zero terminal SNR: True Debiased Estimation: True
UNet weight average magnitude: 0.8033398082829257
UNet weight average strength: 0.010114916750103732
No Text Encoder found in this LoRA
----------------------また、抽出され、弦から変換されるメタを保存することをサポートしています。その後、それらをJSONファイルに保存できます。これらは、メタデータをmeta/alorafile.safetensors-{session_id}.jsonに保存します。
$ python lora-inspector.py ~ /loras/alorafile.safetensors --save_meta$ python lora-inspector.py /mnt/900/training/cyberpunk-anime-21-min-snr/unet-1.15-te-1.15-noise-0.1-steps--linear-DAdaptation-networks.lora/last.safetensors --save_meta
/mnt/900/training/cyberpunk-anime-21-min-snr/unet-1.15-te-1.15-noise-0.1-steps--linear-DAdaptation-networks.lora/last.safetensors
train images: 1005 regularization images: 32000
learning rate: 1.15 unet: 1.15 text encoder: 1.15
epoch: 1 batches: 2025
optimizer: dadaptation.dadapt_adam.DAdaptAdam lr scheduler: linear
network dim/rank: 8.0 alpha: 4.0 module: networks.lora
----------------------体重の平均の大きさと平均強度を見つけます。これらを他のロラと比較して、あなたの体重がどれほど強力かどうかを確認してください。示されている注目の重みは、良い価値に対して決定的ではありません。それらは最初の例です。
$ python lora-inspector.py /mnt/900/lora/studioGhibliStyle_offset.safetensors -w
UNet weight average magnitude: 4.299801171795097
UNet weight average strength: 0.01127891692482733
Text Encoder weight average magnitude: 3.128134997225176
Text Encoder weight average strength: 0.00769676965767913タグの頻度(コンマで区切られた単語)を示します。トリガーワードは、トレーニングデータセット全体でその単語を使用するため、一般的に最も頻繁です。
$ python lora-inspector.py -t /mnt/900/lora/booscapes.safetensors
...
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Tags
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
4k photo” 23
spectacular mountains 17
award winning nature photo 16
ryan dyar 14
image credit nasa nat geo 11
sunset in a valley 11
garden 10
british columbia 10
dramatic autumn landscape 10
autumn mountains 10
an amazing landscape image 10
austria 9
nature scenery 9
pristine water 9
boreal forest 9
scenic view of river 9
alpes 9
mythical floral hills 8
misty environment 8
a photo of a lake on a sunny day 8
majestic beautiful world 8
breathtaking stars 8
lush valley 7
dramatic scenery 7
solar storm 7
siberia 7
cosmic skies 7
dolomites 7
oregon 6
landscape photography 4k 6
very long spires 6
beautiful forests and trees 6
wildscapes 6
mountain behind meadow 6
colorful wildflowers 6
photo of green river 6
beautiful night sky 6
switzerland 6
natural dynamic range color 6
middle earth 6
jessica rossier color scheme 6
arizona 6
enchanting and otherworldly 6
ディレクトリと画像の数を使用したデータセットのかなり基本的なビュー。
$ python lora-inspector.py -d /mnt/900/lora/booscapes.safetensors
Dataset dirs: 2
[source] 50 images
[p7] 4 images
エポック:エポックはデータセット全体を一度見ています
エポックごとのバッチ:各エポックごとにバッチ数(勾配蓄積ステップは含まれません)
勾配蓄積ステップ:勾配蓄積ステップ
トレーニング画像:あなたが持っているトレーニング画像の数
正規化画像:正規化画像の数
スケジューラ:学習率スケジューラ(Cosine、cosine_with_restart、linear、constant、…)
オプティマイザー:オプティマイザー(Adam、Prodigy、Dadaptation、Lion、…)
ネットワークDIM/ランク:LORAネットワークのランク
アルファ:ロラネットワークのランクへのアルファ
モジュール:ネットワークを作成したPythonモジュール
ノイズオフセット:ノイズオフセットオプション
適応ノイズスケール:適応型ノイズスケール
IPノイズガンマ:入力摂動ノイズガンマ入力摂動により、拡散モデルの露出バイアスが減少します
…推論時間予測エラーをシミュレートするためにグラウンドトゥルースサンプルを摂動することで構成される非常にシンプルだが効果的なトレーニングの正則化を提案します。
マルチレイズノイズ割引:マルチライスノイズ割引(拡散モデルトレーニングのためのマルチ解像度ノイズを参照)
マルチレイズノイズスケール:マルチレイズノイズスケール
平均の大きさ:それぞれの体重を平方にし、それらを合わせて、平方根を取得します
平均強度:それぞれの重量、合計して平均を取得する
衰弱の推定損失:拡散モデルのトレーニング
メタデータ値を更新する簡単なスクリプト。この値を使用して適切な名前を設定するアプリケーションのss_output_name変更するのに役立ちます。
現在のメタデータ値を確認するには、 lora-inspector.py --save_meta ...を使用してメタデータを保存し、JSONファイルを検査します。
$ python update_metadata.py --help
usage: update_metadata.py [-h] [--key KEY] [--value VALUE] safetensors_file
positional arguments:
safetensors_file
options:
-h, --help show this help message and exit
--key KEY Key to change in the metadata
--value VALUE Value to set to the metadata
$ python update_metadata.py /mnt/900/lora/testing/armored-core-2023-08-02-173642-ddb4785e.safetensors --key ss_output_name --value mechBOO_v2
Updated ss_output_name with mechBOO_v2
Saved to /mnt/900/lora/testing/armored-core-2023-08-02-173642-ddb4785e.safetensors
--weightsを使用すると、Lora UNETとテキストエンコーダーの重みの平均的な大きさと強度を確認できます。 blackを使用してフォーマットされています。
他に何を見たいですか?問題またはPRを作成します。
これが拡張できるユースケース/アイデア: