DeepFaceLab 2.0 Pretraining Tutorial

Deepfakery
15 Feb 202311:38

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

00:00

👨‍💻 Deep Fake プロセスの高速化

このパラグラフでは、Deep Face Labを使って事前学習されたモデルを作成することで、Deep Fakeプロセスを高速化する方法を説明しています。千葉のイメージから成る顔セットを使用して、様々な角度、表情、色、照明条件を備えたモデルを事前学習することができます。Deep Face Labには、Flickr Faces HQデータセットから派生した顔セットが含まれており、これを使ってモデルの事前学習を行うことができます。事前学習には他のイメージや動画は必要ありません。

05:02

🧩 事前学習モデルの設定

このパラグラフでは、SAE HDトレーナーの事前学習設定について詳しく説明しています。GPUのVRAM容量に基づいて設定を選択し、バッチサイズ、解像度、顔のタイプ、アーキテクチャ、オートエンコーダーのパラメータなど、様々な設定を適切に設定する必要があります。これらの設定は、モデルのパフォーマンスと品質に大きな影響を与えます。トレーニングプロセスの進行状況は、ロスグラフとプレビューイメージから確認できます。

10:03

🏁 事前学習のプロセスとトラブルシューティング

このパラグラフでは、実際の事前学習プロセスとトレーニングの進行状況の監視方法について説明しています。トレーニング中に発生する可能性のあるエラーやトラブルシューティングの方法についても触れています。バッチサイズを徐々に引き上げていき、システムのリソースを有効活用することが重要です。また、事前学習を継続的に行うことができ、いつでもモデルを保存して後で再開することが可能です。最後に、事前学習済みのモデルを共有する方法と、より詳しい情報を得られるリソースについて言及しています。

Mindmap

Keywords

💡ディープフェイク

人工知能を使って人の顔を置き換える技術のことです。この動画ではディープフェイクを作成する方法を解説しています。「ディープフェイク」という言葉がビデオスクリプト全体で多く使われており、この動画の中心テーマとなっています。

💡事前学習

事前にたくさんの画像を使ってモデルを学習させておくことです。この動画ではディープフェイクを作成するための事前学習モデルを作成する方法を説明しています。「事前学習モデル」「事前学習」という言葉がスクリプトで多く使われています。

💡顔セット

事前学習のために使用される数千枚の様々な顔の画像のセットのことです。ディープフェイクラボには「フリッカーフェイスHQ」と呼ばれる顔セットが含まれています。顔セットを使って事前学習モデルを作成することが説明されています。

💡モデル設定

ディープフェイクを生成するための設定のことです。VRAMの量、モデルのアーキテクチャ、バッチサイズなど、様々なパラメーターを設定する必要があります。この動画では、適切なモデル設定を選択する方法を詳しく解説しています。

💡VRAM

グラフィックカードのビデオメモリのことです。ディープフェイクを作成するためには、高性能なグラフィックカードが必要で、VRAMが多いほど高画質の出力ができます。この動画ではVRAMの量に基づいて適切なモデル設定を選択する方法が説明されています。

💡バッチサイズ

ディープフェイクモデルの学習時に1回の反復で処理される画像の枚数のことです。バッチサイズを調整することで、システムリソースの使用量を制御できます。この動画では、適切なバッチサイズを見つけるための方法が詳しく解説されています。

💡解像度

出力される画像の精細さを決める要因のひとつです。解像度を高くすると画質が向上しますが、VRAMも多く必要になります。この動画では、VRAMの量に合わせて適切な解像度を設定する方法が解説されています。

💡モデルアーキテクチャ

ディープフェイクモデルの構造のことです。DFとLiAEという2つの主要なアーキテクチャがあり、それぞれ元画像や出力画像への類似性に違いがあります。この動画ではモデルアーキテクチャの選び方について説明されています。

💡自動エンコーダ

ディープフェイクモデルの重要な部分で、入力画像の顔の特徴を抽出して圧縮し、次にその情報を使って出力画像を生成します。自動エンコーダのパラメータを調整することで、モデルの精度を上げることができます。この動画ではその設定方法が説明されています。

💡過学習

モデルが学習データに過剰に適合し、一般化性能が低下することです。グラフが平坦になり、生成された顔画像が元画像に非常によく似た時点で、過学習が起きていると判断できます。この動画では、過学習を避けるためのタイミングで学習を停止する方法が説明されています。

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

play00:00

today I'm going to show you how to speed

play00:02

up the Deep fake process by creating

play00:04

pre-trained models this video will also

play00:06

serve as a primer for those who are

play00:08

unfamiliar with the Deep face lab

play00:10

training settings

play00:11

a pre-trained model is created with a

play00:14

face set consisting of thousands of

play00:15

images with a wide variety of angles

play00:18

facial expressions color and lighting

play00:20

condition deep face lab includes such a

play00:23

face set derived from the flicker faces

play00:25

HQ data set

play00:27

to get started pre-training a model the

play00:29

only thing you need is deep face lap no

play00:31

other images or videos are required

play00:33

since the quick 96 and amp models do not

play00:36

offer a pre-training option this video

play00:38

will focus on the SAE HD trainer which

play00:41

is the standard for most deep fakes

play00:44

first off if you want to view modify or

play00:47

replace the default pre-trained face set

play00:49

then navigate to the internal

play00:50

pre-trained faces folder copy this file

play00:53

over to one of your aligned folders and

play00:55

use the unpack script now you can check

play00:58

the faces and add or remove images if

play01:00

you like otherwise go ahead and delete

play01:02

these files if you do want to use your

play01:05

own images simply use the pack script

play01:07

then drop the resulting faceset.pac file

play01:10

into the pre-trained faces folder making

play01:12

sure to remove or rename the default

play01:14

face set first similarly if you

play01:17

downloaded a pre-trained face it just

play01:19

drop the dot pack file into that folder

play01:22

now let's get into the model pre-trained

play01:24

settings if you tried the SAE HD trainer

play01:27

already you may have been overwhelmed by

play01:29

the numerous options don't worry because

play01:32

during pre-training we won't need to use

play01:34

most of these options and in fact the

play01:36

software will override several of them

play01:38

the goal here is to manage your vram and

play01:41

get the model trainer running on your

play01:43

system

play01:43

for now we'll focus on the main model

play01:46

architecture and parameters and I'll

play01:48

show you how to figure out what numbers

play01:49

to enter

play01:50

head over to

play01:52

deepphakedvfx.com and under guides go to

play01:56

model training settings this table will

play01:58

help you choose settings suggested by

play02:00

other deep face lab users that might

play02:02

work on your Hardware

play02:04

start with the vram drop down and choose

play02:06

the amount of vram that your GPU has and

play02:09

maybe a couple of others for instance if

play02:11

you have an 11 gigabyte card you might

play02:13

choose 11 and 12. in this tutorial we'll

play02:16

be using the liae architecture so you

play02:20

might select that option as well

play02:22

these settings are merely suggestions

play02:24

and you can easily follow along by using

play02:26

the default values in the next section

play02:29

keep this window open and head back to

play02:31

your deep face lab folder

play02:33

now run the file labeled 6 train

play02:37

saehd.bat the first thing you need to do

play02:40

is give the model a name one naming

play02:42

convention you can follow is to include

play02:44

some of the model parameters in the name

play02:46

for easy reference

play02:48

keep it short and try to avoid using

play02:50

special characters or spaces

play02:52

the next step is to choose your device

play02:54

from the list of CPUs and gpus you will

play02:57

probably be using the first GPU which is

play03:00

pre-selected as index 0. so just hit

play03:02

enter or type in the index of another

play03:04

device if you have multiple similar gpus

play03:07

you can use both simultaneously by

play03:10

entering each index separated by a comma

play03:12

like so

play03:13

it's recommended that if you have

play03:15

multiple gpus they be of the same model

play03:17

or at least the same vram capacity also

play03:20

note that you cannot combine CPU and GPU

play03:23

training together

play03:24

we can set the auto backup to one or two

play03:27

hours and hit enter

play03:28

leave the right preview history at the

play03:30

default offsetting by pressing enter

play03:33

you can set the target iteration to stop

play03:35

the training at a specific point or

play03:37

leave it at zero for uninterrupted

play03:39

training flip source and flip

play03:42

destination randomly can both be left at

play03:44

their default values

play03:46

now for the batch size which sets how

play03:48

many images are to be processed per

play03:50

iteration this is also the main setting

play03:53

that you can change throughout training

play03:55

to throttle system resource usage to a

play03:57

stable level go back to the model

play03:59

settings table if needed and select one

play04:02

of the entries to use as your Baseline

play04:04

settings from here on input the batch

play04:06

size listed there or if you're unsure

play04:08

just go with the default values for now

play04:10

the only caveat is that the batch size

play04:13

must be divisible evenly between all

play04:15

gpus being used for instance if I had

play04:18

two gpus my batch slides would always

play04:21

need to be an even number if I had three

play04:23

gpus the batch size would need to be

play04:25

divisible by 3 and so on

play04:27

next is the resolution which is the main

play04:30

determining factor in the clarity of the

play04:32

resulting deep fig

play04:33

obviously higher is better in most cases

play04:36

but there's a limit to how much your GPU

play04:38

can handle always choose a resolution

play04:41

that is divisible by 16 or by 32 if you

play04:45

are using the Dash D architecture option

play04:47

which we will get to in a moment enter

play04:50

the number from the table or hit enter

play04:51

to use the default the face type is how

play04:54

much of the person's face will be

play04:56

considered during training most people

play04:58

use WF which stands for whole face if

play05:01

you're not familiar with face types

play05:03

please have a look at my face set

play05:04

extraction tutorial or the guide on deep

play05:07

fake vfx.com for a complete breakdown

play05:09

again I recommend using WF so type that

play05:13

in and hit enter

play05:14

there are two types of model

play05:16

architectures as well as three standard

play05:18

options which you will combine

play05:20

DF is the original Deep Pig architecture

play05:23

and it tends to be more biased toward

play05:25

the source material

play05:27

liae on the other hand has an easier

play05:30

time picking up the qualities of the

play05:32

destination images

play05:34

as for the options you can add any of

play05:36

these to the model for a better result

play05:38

however you will be using more vram when

play05:41

they are enabled

play05:42

the U option increases similarity to the

play05:45

source

play05:46

the D option doubles the resolution

play05:49

and the T option also increases Source

play05:51

likeness

play05:52

I recommend entering liae

play05:56

liae-u or liae-ud for the architecture

play06:00

type

play06:01

the next group of options are used to

play06:03

define the dimensions of the autoencoder

play06:05

this is where things start to get a

play06:07

little more scientific so I'm not going

play06:10

to go too deep on this frankly if you

play06:12

want to know more you're going to have

play06:14

to do your own research on auto encoders

play06:16

and neural networks in general this

play06:19

affects the model's Precision in

play06:20

detecting and reproducing facial

play06:22

features colors Etc here again higher

play06:25

numbers are usually better but they come

play06:27

at the expense of vram

play06:29

enter the numbers you found in the table

play06:31

or continue using the defaults mask

play06:34

training eyes and mouth priority uniform

play06:37

yaw and blur out mask can all use the

play06:39

default values by pressing enter

play06:41

model and optimizers on GPU may come

play06:44

into play later if you can't run the

play06:46

model but we'll leave it on for now

play06:48

add a belief is what's called an

play06:50

Optimizer but what you really need to

play06:52

know is that this might make your deep

play06:54

fake look better while again using more

play06:56

vram leave it on for now

play06:58

learning rate Dropout random warp random

play07:01

hsl Gan style Powers color transfer mode

play07:05

and gradient clipping can all be kept at

play07:07

the default values finally of course we

play07:10

will enable pre-train mode

play07:13

now comes the moment of truth either the

play07:15

training window will open or you'll get

play07:17

an error most likely an out of memory or

play07:20

oom error if your model crashes I'll

play07:23

explain what to do in the following

play07:24

section

play07:25

let's have a quick look at the SAE HD

play07:28

trainer interface

play07:30

in the command prompt window you'll see

play07:32

the model summary which shows all of the

play07:34

settings you entered please note that

play07:36

the settings which have an override

play07:37

value during pre-training will not

play07:39

display the current values at the bottom

play07:42

of the window are some sets of numbers

play07:44

which will show the model training

play07:45

progress

play07:46

from left to right these are the system

play07:48

time the current iteration count time to

play07:52

process the current iteration The Source

play07:54

loss value and the destination loss

play07:56

value

play07:57

these loss values represent the accuracy

play08:00

of the training and will approach zero

play08:02

over time so the lower the value the

play08:04

better the result should be these

play08:06

numbers will continually be updated as

play08:09

the training progresses but if the

play08:10

numbers stop updating that means the

play08:12

trainer has frozen and will likely crash

play08:16

the training preview window shows a list

play08:18

of commands a graph of loss values and a

play08:21

preview image of the training process

play08:23

you can save or back up the training or

play08:26

hit enter to stop training you can

play08:28

easily restart training at any time by

play08:31

running the train SAE HD script again if

play08:34

you would like to refresh the preview

play08:36

image press the P key to update the

play08:39

spacebar Cycles through preview modes

play08:41

showing masked and unmasked versions the

play08:44

L key changes the range history of the

play08:46

graph which will be helpful as the model

play08:48

reaches many thousands or millions of

play08:50

iterations once you have the

play08:52

pre-training running you should consider

play08:54

raising the batch size for faster

play08:56

training with the preview Windows

play08:58

selected hit enter to save and stop

play09:00

training run the train SAE HD script

play09:03

again and this time hit enter when

play09:05

prompted before the trainer starts now

play09:08

you can modify some of the settings such

play09:10

as the batch size

play09:12

raise the batch size by one or two

play09:14

points and for the rest of the settings

play09:15

just hit enter to keep the same values

play09:18

if the trainer runs stop it and raise

play09:20

the batch size again keep raising it

play09:23

until the trainer crashes and you get an

play09:25

oom error then back it off by one or two

play09:28

points now you should be training at the

play09:31

fastest rate your system can handle

play09:32

given the other model parameters you

play09:34

entered if you can't run the model

play09:37

you're going to have to modify some of

play09:39

the values we entered previously enter

play09:41

all the same settings again but this

play09:43

time use a lower batch size if you end

play09:46

up having to lower the batch size to 4

play09:48

or less then that is a good indication

play09:50

that you need to adjust the other model

play09:52

parameters

play09:53

try it with add a belief disabled or use

play09:56

liae instead of

play09:58

liae-ud you can turn off opton GPU to

play10:02

free up some vram but you'll probably be

play10:05

using more CPU resources during training

play10:07

and the speed will be slower lowering

play10:10

the resolution will have a dramatic

play10:11

impact on the vram usage but of course

play10:14

will affect the final quality you can

play10:16

also lower the various autoencoder

play10:18

Dimensions while keeping the same ratio

play10:20

between them if you get any other errors

play10:23

they may be due to using the wrong

play10:25

version of Deep face lap or that you

play10:27

need to optimize your system check out

play10:29

my deep face lab installation tutorial

play10:32

video and my full guide at Deep fake

play10:34

vfx.com for more tips on getting set up

play10:37

at this point you're probably wondering

play10:39

how long to pre-train the model since

play10:42

there is no way to define how long a

play10:44

deep fake model should be trained you

play10:46

will use the Lost graph and preview

play10:48

image to decide for yourself when to

play10:50

stop

play10:50

once the graph flattens out and the

play10:53

trained faces look similar to the

play10:54

original images you can save back up and

play10:58

exit the trainer remember that you can

play11:00

continue pre-training at any time which

play11:02

means that you can use the model for a

play11:04

deep thick right now and come back to it

play11:06

later on go to the model folder backups

play11:09

and save a copy of the most recent

play11:11

folder usually number one when you want

play11:14

to continue pre-training simply drop

play11:16

these files into the model folder and

play11:18

run the SAE HD trainer again

play11:21

if you have a pre-trained model you'd

play11:23

like to share with the community log in

play11:25

to deepfakevfx.com where you'll be able

play11:28

to download pre-trained models and

play11:30

submit your model to be listed in the

play11:31

archive

play11:33

if you like this video help me out with

play11:34

a thumbs up and as always thanks for

play11:36

watching

Rate This

5.0 / 5 (0 votes)

Do you need a summary in English?