DeepFaceLab 2.0 Pretraining Tutorial
Summary
TLDRこの動画では、Deepfake作成の前処理プロセスを高速化する方法と、Deepfacelabトレーニングの基本的な設定について説明しています。前処理済みモデルの作成には、顔の画像セットを使用し、GPUのVRAM容量に応じた適切なトレーニング設定を選択する必要があります。ビデオでは、モデルのアーキテクチャ、オートエンコーダーの次元、その他の重要なパラメーターの設定方法や、システムリソースの最適化とエラーの回避に役立つ情報を提供しています。さらに、適切なタイミングでモデルをバックアップし、共有する方法についても説明されています。
Takeaways
- 👨💻 Deep Fakeの処理を高速化するための事前学習モデルの作成方法を紹介します。
- 🔑 Deep Face Labのトレーニング設定の概要を解説します。
- 📁 事前トレーニング用のフェイスセットを使用し、独自のデータセットを追加・削除することができます。
- 🧠 vRAMの容量と使用可能なGPUに基づいて、モデルアーキテクチャやパラメータを選択する必要があります。
- ⚙️ バッチサイズ、解像度、アーキテクチャタイプなどのさまざまな設定を入力する必要があります。
- 🔢 オートエンコーダの次元を定義する必要があり、これは精度に影響を与えます。
- 👀 トレーニングプレビューウィンドウでモデルの進行状況を確認できます。
- ⌛ モデルの損失値がグラフで平坦化したときにトレーニングを停止することができます。
- 🔄 モデルのバックアップを作成し、後で続きからトレーニングを再開できます。
- 🌐 事前トレーニングされたモデルをコミュニティと共有することができます。
Q & A
動画の目的は何ですか?
-この動画では、Deepfacelabを使ってDeep Fakeプロセスを高速化する方法を紹介しています。具体的には事前学習モデルの作成方法について説明しており、Deepfacelabのトレーニング設定に馴染みのない視聴者向けの入門編としても機能します。
事前学習モデルを作成するために必要なものは何ですか?
-事前学習モデルを作成するためには、Deepfacelabのみが必要です。他の画像やビデオは必要ありません。なぜなら、ソフトウェアには、Flickr Faces HQデータセットから作成された、角度、表情、色、照明条件の異なる数千枚の画像から構成される事前学習用の顔セットが含まれているからです。
デフォルトの事前学習用顔セットを変更・修正・置換するにはどうすればよいですか?
-デフォルトの事前学習顔セットを変更したり修正したい場合は、「internal pre-trained faces」フォルダに移動し、ファイルをコピーして対応するaligned フォルダに貼り付けます。そして、アンパックスクリプトを使用してファイルを展開します。これにより、顔を確認したり、画像を追加または削除することができます。
独自の画像を使用する場合はどうすればよいですか?
-独自の画像を使いたい場合は、パックスクリプトを使ってファイルをパックしてください。その後、生成されたfaceset.pacファイルをpre-trained facesフォルダに移動し、デフォルトの顔セットファイルを削除または名前を変更してください。他の事前学習済み顔セットをダウンロードした場合は、.pacファイルをそのままpre-trained facesフォルダにドロップするだけでOKです。
SAE HDトレーナーのオプションには何が含まれていますか?
-SAE HDトレーナーには多くのオプションが含まれており、初見ですと圧倒されるかもしれません。しかし、事前学習中に使用するのは、そのうちの一部に限られます。またソフトウェアが一部のオプションを上書きします。ここでは主なモデルアーキテクチャとパラメータに焦点を当て、どの数値を入力すればよいかを示します。
モデル設定を選択する際にはどのリソースが役立ちますか?
-モデル設定を選択する際にはdeepfakedvfx.comの「Model Training Settings」ガイドが役立ちます。このテーブルでは、GPUのVRAMやアーキテクチャ、他の設定に関して、他のDeepfacelabユーザーが提案する設定を見ることができます。これらはあくまで提案であり、デフォルト値を使用しても問題ありません。
バッチサイズの選び方はどうすればよいですか?
-バッチサイズは、1回のイテレーションで処理される画像の数を設定します。これは、トレーニング中にシステムリソースの使用状況を安定させるために調整できる主要なパラメーターです。最初は、モデル設定テーブルの提案されている値を使うか、デフォルト値を使うのがよいでしょう。ただし、バッチサイズはGPUの数で割り切れる数値でなければなりません。例えば2つのGPUを使う場合はバッチサイズは偶数、3つのGPUを使う場合は3の倍数でなければならない、といった具合です。
ディープフェイクの品質を決めるのはどのパラメーターですか?
-Deep Fakeの品質を左右する主なパラメーターは解像度です。GPUの性能に応じて設定できる範囲内で、できるだけ高い解像度を選ぶことが大切です。解像度は16の倍数、-Dアーキテクチャオプションを使う場合は32の倍数でなければなりません。
Liae - udアーキテクチャを選択する理由は何ですか?
-Liaeアーキテクチャはディープフェイクアーキテクチャに比べ、目的の画像の質を良く写し取れる傾向にあります。オプションのuはソース側との類似度を上げ、dは解像度を2倍にします。liae-udを選ぶと、ソースへの類似性と解像度の両方が高まるため、このアーキテクチャを選ぶのがおすすめです。
モデルが起動せずにエラーが発生した場合はどうすればよいですか?
-モデルが起動せずにメモリ不足(OOM)エラーなどが発生した場合、設定値をいくつか修正する必要があります。バッチサイズを下げてみるのが最初の手です。4以下まで下げないといけない場合は、他のモデルパラメータも調整する必要があるサインです。そこで add_beliefを無効にしたり、liaeではなくliae-udを使ってみるのがよいでしょう。MODEL AND OPTIMIZERS ONGPUをオフにすることもVRAMを節約できます。解像度を下げる、オートエンコーダのディメンションを比例して下げるなどの手もあります。他のエラーの場合は、Deepfacelabの最新バージョンを使っているか、システムの最適化が必要かもしれません。
Outlines
👨💻 Deep Fake プロセスの高速化
このパラグラフでは、Deep Face Labを使って事前学習されたモデルを作成することで、Deep Fakeプロセスを高速化する方法を説明しています。千葉のイメージから成る顔セットを使用して、様々な角度、表情、色、照明条件を備えたモデルを事前学習することができます。Deep Face Labには、Flickr Faces HQデータセットから派生した顔セットが含まれており、これを使ってモデルの事前学習を行うことができます。事前学習には他のイメージや動画は必要ありません。
🧩 事前学習モデルの設定
このパラグラフでは、SAE HDトレーナーの事前学習設定について詳しく説明しています。GPUのVRAM容量に基づいて設定を選択し、バッチサイズ、解像度、顔のタイプ、アーキテクチャ、オートエンコーダーのパラメータなど、様々な設定を適切に設定する必要があります。これらの設定は、モデルのパフォーマンスと品質に大きな影響を与えます。トレーニングプロセスの進行状況は、ロスグラフとプレビューイメージから確認できます。
🏁 事前学習のプロセスとトラブルシューティング
このパラグラフでは、実際の事前学習プロセスとトレーニングの進行状況の監視方法について説明しています。トレーニング中に発生する可能性のあるエラーやトラブルシューティングの方法についても触れています。バッチサイズを徐々に引き上げていき、システムのリソースを有効活用することが重要です。また、事前学習を継続的に行うことができ、いつでもモデルを保存して後で再開することが可能です。最後に、事前学習済みのモデルを共有する方法と、より詳しい情報を得られるリソースについて言及しています。
Mindmap
Keywords
💡ディープフェイク
💡事前学習
💡顔セット
💡モデル設定
💡VRAM
💡バッチサイズ
💡解像度
💡モデルアーキテクチャ
💡自動エンコーダ
💡過学習
Highlights
Introduction to speeding up the Deepfake process using pre-trained models.
Explanation of pre-trained models with a face set from Flickr Faces HQ dataset.
DeepFaceLab's SAE HD trainer focus for pre-training.
How to view, modify, or replace the default pre-trained face set.
Using your own images for pre-training by packing and replacing the face set.
Guidance on managing VRAM for successful model training.
Utilizing DeepFakeDVFX.com for model training settings suggestions.
Training model naming conventions and setup process.
Adjusting batch size and resolution for optimal training performance.
Choosing face types and understanding model architectures (LIAE, DF).
Importance of autoencoder dimensions and VRAM management.
Enabling pre-train mode and troubleshooting training issues.
Understanding the SAE HD trainer interface and monitoring training progress.
Tips for optimizing batch size for faster training.
Advice on when to stop pre-training based on loss graph and preview image.
Sharing pre-trained models with the community on DeepFakeDVFX.com.
Transcripts
today I'm going to show you how to speed
up the Deep fake process by creating
pre-trained models this video will also
serve as a primer for those who are
unfamiliar with the Deep face lab
training settings
a pre-trained model is created with a
face set consisting of thousands of
images with a wide variety of angles
facial expressions color and lighting
condition deep face lab includes such a
face set derived from the flicker faces
HQ data set
to get started pre-training a model the
only thing you need is deep face lap no
other images or videos are required
since the quick 96 and amp models do not
offer a pre-training option this video
will focus on the SAE HD trainer which
is the standard for most deep fakes
first off if you want to view modify or
replace the default pre-trained face set
then navigate to the internal
pre-trained faces folder copy this file
over to one of your aligned folders and
use the unpack script now you can check
the faces and add or remove images if
you like otherwise go ahead and delete
these files if you do want to use your
own images simply use the pack script
then drop the resulting faceset.pac file
into the pre-trained faces folder making
sure to remove or rename the default
face set first similarly if you
downloaded a pre-trained face it just
drop the dot pack file into that folder
now let's get into the model pre-trained
settings if you tried the SAE HD trainer
already you may have been overwhelmed by
the numerous options don't worry because
during pre-training we won't need to use
most of these options and in fact the
software will override several of them
the goal here is to manage your vram and
get the model trainer running on your
system
for now we'll focus on the main model
architecture and parameters and I'll
show you how to figure out what numbers
to enter
head over to
deepphakedvfx.com and under guides go to
model training settings this table will
help you choose settings suggested by
other deep face lab users that might
work on your Hardware
start with the vram drop down and choose
the amount of vram that your GPU has and
maybe a couple of others for instance if
you have an 11 gigabyte card you might
choose 11 and 12. in this tutorial we'll
be using the liae architecture so you
might select that option as well
these settings are merely suggestions
and you can easily follow along by using
the default values in the next section
keep this window open and head back to
your deep face lab folder
now run the file labeled 6 train
saehd.bat the first thing you need to do
is give the model a name one naming
convention you can follow is to include
some of the model parameters in the name
for easy reference
keep it short and try to avoid using
special characters or spaces
the next step is to choose your device
from the list of CPUs and gpus you will
probably be using the first GPU which is
pre-selected as index 0. so just hit
enter or type in the index of another
device if you have multiple similar gpus
you can use both simultaneously by
entering each index separated by a comma
like so
it's recommended that if you have
multiple gpus they be of the same model
or at least the same vram capacity also
note that you cannot combine CPU and GPU
training together
we can set the auto backup to one or two
hours and hit enter
leave the right preview history at the
default offsetting by pressing enter
you can set the target iteration to stop
the training at a specific point or
leave it at zero for uninterrupted
training flip source and flip
destination randomly can both be left at
their default values
now for the batch size which sets how
many images are to be processed per
iteration this is also the main setting
that you can change throughout training
to throttle system resource usage to a
stable level go back to the model
settings table if needed and select one
of the entries to use as your Baseline
settings from here on input the batch
size listed there or if you're unsure
just go with the default values for now
the only caveat is that the batch size
must be divisible evenly between all
gpus being used for instance if I had
two gpus my batch slides would always
need to be an even number if I had three
gpus the batch size would need to be
divisible by 3 and so on
next is the resolution which is the main
determining factor in the clarity of the
resulting deep fig
obviously higher is better in most cases
but there's a limit to how much your GPU
can handle always choose a resolution
that is divisible by 16 or by 32 if you
are using the Dash D architecture option
which we will get to in a moment enter
the number from the table or hit enter
to use the default the face type is how
much of the person's face will be
considered during training most people
use WF which stands for whole face if
you're not familiar with face types
please have a look at my face set
extraction tutorial or the guide on deep
fake vfx.com for a complete breakdown
again I recommend using WF so type that
in and hit enter
there are two types of model
architectures as well as three standard
options which you will combine
DF is the original Deep Pig architecture
and it tends to be more biased toward
the source material
liae on the other hand has an easier
time picking up the qualities of the
destination images
as for the options you can add any of
these to the model for a better result
however you will be using more vram when
they are enabled
the U option increases similarity to the
source
the D option doubles the resolution
and the T option also increases Source
likeness
I recommend entering liae
liae-u or liae-ud for the architecture
type
the next group of options are used to
define the dimensions of the autoencoder
this is where things start to get a
little more scientific so I'm not going
to go too deep on this frankly if you
want to know more you're going to have
to do your own research on auto encoders
and neural networks in general this
affects the model's Precision in
detecting and reproducing facial
features colors Etc here again higher
numbers are usually better but they come
at the expense of vram
enter the numbers you found in the table
or continue using the defaults mask
training eyes and mouth priority uniform
yaw and blur out mask can all use the
default values by pressing enter
model and optimizers on GPU may come
into play later if you can't run the
model but we'll leave it on for now
add a belief is what's called an
Optimizer but what you really need to
know is that this might make your deep
fake look better while again using more
vram leave it on for now
learning rate Dropout random warp random
hsl Gan style Powers color transfer mode
and gradient clipping can all be kept at
the default values finally of course we
will enable pre-train mode
now comes the moment of truth either the
training window will open or you'll get
an error most likely an out of memory or
oom error if your model crashes I'll
explain what to do in the following
section
let's have a quick look at the SAE HD
trainer interface
in the command prompt window you'll see
the model summary which shows all of the
settings you entered please note that
the settings which have an override
value during pre-training will not
display the current values at the bottom
of the window are some sets of numbers
which will show the model training
progress
from left to right these are the system
time the current iteration count time to
process the current iteration The Source
loss value and the destination loss
value
these loss values represent the accuracy
of the training and will approach zero
over time so the lower the value the
better the result should be these
numbers will continually be updated as
the training progresses but if the
numbers stop updating that means the
trainer has frozen and will likely crash
the training preview window shows a list
of commands a graph of loss values and a
preview image of the training process
you can save or back up the training or
hit enter to stop training you can
easily restart training at any time by
running the train SAE HD script again if
you would like to refresh the preview
image press the P key to update the
spacebar Cycles through preview modes
showing masked and unmasked versions the
L key changes the range history of the
graph which will be helpful as the model
reaches many thousands or millions of
iterations once you have the
pre-training running you should consider
raising the batch size for faster
training with the preview Windows
selected hit enter to save and stop
training run the train SAE HD script
again and this time hit enter when
prompted before the trainer starts now
you can modify some of the settings such
as the batch size
raise the batch size by one or two
points and for the rest of the settings
just hit enter to keep the same values
if the trainer runs stop it and raise
the batch size again keep raising it
until the trainer crashes and you get an
oom error then back it off by one or two
points now you should be training at the
fastest rate your system can handle
given the other model parameters you
entered if you can't run the model
you're going to have to modify some of
the values we entered previously enter
all the same settings again but this
time use a lower batch size if you end
up having to lower the batch size to 4
or less then that is a good indication
that you need to adjust the other model
parameters
try it with add a belief disabled or use
liae instead of
liae-ud you can turn off opton GPU to
free up some vram but you'll probably be
using more CPU resources during training
and the speed will be slower lowering
the resolution will have a dramatic
impact on the vram usage but of course
will affect the final quality you can
also lower the various autoencoder
Dimensions while keeping the same ratio
between them if you get any other errors
they may be due to using the wrong
version of Deep face lap or that you
need to optimize your system check out
my deep face lab installation tutorial
video and my full guide at Deep fake
vfx.com for more tips on getting set up
at this point you're probably wondering
how long to pre-train the model since
there is no way to define how long a
deep fake model should be trained you
will use the Lost graph and preview
image to decide for yourself when to
stop
once the graph flattens out and the
trained faces look similar to the
original images you can save back up and
exit the trainer remember that you can
continue pre-training at any time which
means that you can use the model for a
deep thick right now and come back to it
later on go to the model folder backups
and save a copy of the most recent
folder usually number one when you want
to continue pre-training simply drop
these files into the model folder and
run the SAE HD trainer again
if you have a pre-trained model you'd
like to share with the community log in
to deepfakevfx.com where you'll be able
to download pre-trained models and
submit your model to be listed in the
archive
if you like this video help me out with
a thumbs up and as always thanks for
watching
5.0 / 5 (0 votes)