Commit graph

77 commits

Author SHA1 Message Date
Colombo
38b85108b3 DFL-2.0 initial branch commit 2020-01-21 18:43:39 +04:00
Colombo
b5c234dac3 no_preview for model 2020-01-04 23:52:12 +04:00
Colombo
50f892d57d all models: removed options 'src_scale_mod', and 'sort samples by yaw as target'
If you want, you can manually remove unnecessary angles from src faceset after sort by yaw.

Optimized sample generators (CPU workers). Now they consume less amount of RAM and work faster.

added
4.2.other) data_src/dst util faceset pack.bat
	Packs /aligned/ samples into one /aligned/samples.pak file.
	After that, all faces will be deleted.

4.2.other) data_src/dst util faceset unpack.bat
	unpacks faces from /aligned/samples.pak to /aligned/ dir.
	After that, samples.pak will be deleted.

Packed faceset load and work faster.
2019-12-21 23:16:55 +04:00
Colombo
1f350ae413 1 2019-11-09 19:23:55 +04:00
Colombo
24eac44dd9 fix random_flip option bug 2019-10-14 14:08:36 +04:00
Colombo
92f14dee70 SAEHD: added option Enable random warp of samples, default is on
Random warp is required to generalize facial expressions of both faces. When the face is trained enough, you can disable it to get extra sharpness for less amount of iterations.
2019-10-12 10:31:50 +04:00
Colombo
e15f846d08 SAE, SAEHD: random flip and learn mask options now can be overridden 2019-10-10 22:56:57 +04:00
Colombo
ac7725163d removed SAEv2,
added SAEHD model ( High Definition Styled AutoEncoder )
This is a new heavyweight model for high-end cards to achieve maximum possible deepfake quality in 2020.
Differences from SAE:
+ new encoder produces more stable face and less scale jitter
  before: https://i.imgur.com/4jUcol8.gifv
  after:  https://i.imgur.com/lyiax49.gifv - scale of the face is less changed within frame size
+ new decoder produces subpixel clear result
+ pixel loss and dssim loss are merged together to achieve both training speed and pixel trueness
+ by default networks will be initialized with CA weights, but only after first successful iteration
  therefore you can test network size and batch size before weights initialization process
+ new neural network optimizer consumes less VRAM than before
+ added option <Enable 'true face' training>
  The result face will be more like src and will get extra sharpness.
  example: https://i.imgur.com/ME3A7dI.gifv
  Enable it for last 15-30k iterations before conversion.
+ encoder and decoder dims are merged to one parameter encoder/decoder dims
+ added mid-full face, which covers 30% more area than half face.
2019-10-08 15:09:28 +04:00
Colombo
dc11ec32be SAE : WARNING, RETRAIN IS REQUIRED !
fixed model sizes from previous update.
avoided bug in ML framework(keras) that forces to train the model on random noise.

Converter: added blur on the same keys as sharpness

Added new model 'TrueFace'. This is a GAN model ported from https://github.com/NVlabs/FUNIT
Model produces near zero morphing and high detail face.
Model has higher failure rate than other models.
Keep src and dst faceset in same lighting conditions.
2019-09-19 11:13:56 +04:00
Colombo
b6b92bded0 converter: now writes a filename of current frame config,
SAE: removed multiscale decoder, because it's not effective
2019-09-13 08:59:00 +04:00
Colombo
7ed38a8097 Converter:
Session is now saved to the model folder.

blur and erode ranges are increased to -400+400

hist-match-bw is now replaced with seamless2 mode.

Added 'ebs' color transfer mode (works only on Windows).

FANSEG model (used in FAN-x mask modes) is retrained with new model configuration
and now produces better precision and less jitter
2019-09-07 13:57:42 +04:00
iperov
407ce3b1ca Added interactive converter.
With interactive converter you can change any parameter of any frame and see the result in real time.

Converter: added motion_blur_power param.
Motion blur is applied by precomputed motion vectors.
So the moving face will look more realistic.

RecycleGAN model is removed.

Added experimental AVATAR model. Minimum required VRAM is 6GB (NVIDIA), 12GB (AMD)
Usage:
1) place data_src.mp4 10-20min square resolution video of news reporter sitting at the table with static background,
   other faces should not appear in frames.
2) process "extract images from video data_src.bat" with FULL fps
3) place data_dst.mp4 video of face who will control the src face
4) process "extract images from video data_dst FULL FPS.bat"
5) process "data_src mark faces S3FD best GPU.bat"
6) process "data_dst extract unaligned faces S3FD best GPU.bat"
7) train AVATAR.bat stage 1, tune batch size to maximum for your card (32 for 6GB), train to 50k+ iters.
8) train AVATAR.bat stage 2, tune batch size to maximum for your card (4 for 6GB), train to decent sharpness.
9) convert AVATAR.bat
10) converted to mp4.bat

updated versions of modules
2019-08-24 12:57:29 +04:00
Auroir
c4e68ef539 Formatted Model Summary (#348)
* Formatted Model Summary

Aligns the model summary output using f-string formatting. The logic structure of the base class has not been changed, only the lines put into `model_summary_text`. Output width is calculated from keys & values and will scale to show a clean summary for any model/platform.

GPU VRAM has been added as an output. Incorrect detection of VRAM is possible in broken environments and GPUs of different sizes can report the same name. Showing it here adds clarity for the user and for issue tickets.

Concatenation changed from "\r\n" to "\n", CRLF end of lines for Windows are handled transparently so using it here caused extra blank lines in the summary txt file.

**Examples:**
Using CUDA + SAE-LIAE
```
============= Model Summary ==============
==                                      ==
==         Model name: SAE              ==
==                                      ==
==  Current iteration: 16               ==
==                                      ==
==----------- Model Options ------------==
==                                      ==
==         batch_size: 4                ==
==        sort_by_yaw: False            ==
==        random_flip: True             ==
==         resolution: 128              ==
==          face_type: f                ==
==         learn_mask: True             ==
==     optimizer_mode: 1                ==
==              archi: liae             ==
==            ae_dims: 256              ==
==          e_ch_dims: 42               ==
==          d_ch_dims: 21               ==
== multiscale_decoder: False            ==
==         ca_weights: False            ==
==         pixel_loss: False            ==
==   face_style_power: 0.0              ==
==     bg_style_power: 0.0              ==
==    apply_random_ct: False            ==
==           clipgrad: False            ==
==                                      ==
==------------- Running On -------------==
==                                      ==
==       Device index: 0                ==
==               Name: GeForce GTX 1080 ==
==               VRAM: 8.00GB           ==
==                                      ==
==========================================
```
Colab
```
========== Model Summary ==========
==                               ==
==         Model name: SAE       ==
==                               ==
==  Current iteration: 39822     ==
==                               ==
==-------- Model Options --------==
==                               ==
==         batch_size: 24        ==
==        sort_by_yaw: True      ==
==        random_flip: False     ==
==         resolution: 128       ==
==          face_type: f         ==
==         learn_mask: True      ==
==     optimizer_mode: 2         ==
==              archi: liae      ==
==            ae_dims: 222       ==
==          e_ch_dims: 34        ==
==          d_ch_dims: 16        ==
== multiscale_decoder: True      ==
==         ca_weights: True      ==
==         pixel_loss: False     ==
==   face_style_power: 2.0       ==
==     bg_style_power: 1.5       ==
==    apply_random_ct: False     ==
==           clipgrad: True      ==
==                               ==
==--------- Running On ----------==
==                               ==
==       Device index: 0         ==
==               Name: Tesla K80 ==
==               VRAM: 11.00GB   ==
==                               ==
===================================
```
Using OpenCL + H128
```
=========================== Model Summary ===========================
==                                                                 ==
==        Model name: H128                                         ==
==                                                                 ==
== Current iteration: 0                                            ==
==                                                                 ==
==------------------------- Model Options -------------------------==
==                                                                 ==
==        batch_size: 4                                            ==
==       sort_by_yaw: False                                        ==
==       random_flip: True                                         ==
==        lighter_ae: False                                        ==
==        pixel_loss: False                                        ==
==                                                                 ==
==-------------------------- Running On ---------------------------==
==                                                                 ==
==      Device index: 0                                            ==
==              Name: Advanced Micro Devices, Inc. gfx900 (OpenCL) ==
==              VRAM: 7.98GB                                       ==
==                                                                 ==
=====================================================================
```
Using CPU (output trimmed)
```
==------- Running On --------==
==                           ==
==       Using device: CPU   ==
==                           ==
===============================
```
multi_gpu support is retained (output trimmed)
```
==------------- Running On -------------==
==                                      ==
==    Using multi_gpu: True             ==
==                                      ==
==       Device index: 1                ==
==               Name: Geforce GTX 1080 ==
==               VRAM: 8.00GB           ==
==       Device index: 2                ==
==               Name: Geforce GTX 1080 ==
==               VRAM: 8.00GB           ==
==                                      ==
==========================================
```

Low VRAM warning (output trimmed)
```
==------------- Running On -------------==
==                                      ==
==       Device index: 0                ==
==               Name: Geforce GTX 1050 ==
==               VRAM: 2.00GB           ==
==                                      ==
==========================================
/!\
/!\ WARNING:
/!\ You are using a GPU with 2GB or less VRAM. This may significantly reduce the quality of your result!
/!\ If training does not start, close all programs and try again.
/!\ Also you can disable Windows Aero Desktop to increase available VRAM.
/!\
```

* Fix indent
2019-08-16 18:35:27 +04:00
iperov
e8c5f168bd Merge branch 'master' of https://github.com/iperov/DeepFaceLab 2019-08-11 11:17:38 +04:00
iperov
b72d5a3f9a fixed error "Failed to get convolution algorithm" on some systems
fixed error "dll load failed" on some systems
Expanded eyebrows line of face masks. It does not affect mask of FAN-x converter mode.
2019-08-11 11:17:22 +04:00
Josh Johnson
e2bc65d5f0 Fix issue with RTX GPU and TensorFlow (#322)
An issue affecting at least 2070 and 2080 cards (possibly other RTX cards too) requires auto growth to be enabled for TensorFlow to work.

I don't know enough about the impact of this change to know whether this ought to be made optional or not, but for RTX owners, this simple change fixes TensorFlow errors when generating models.
2019-08-02 16:40:41 +04:00
fakerdaker
582c974851 Colab choose random preview (#316) 2019-07-25 11:29:31 +04:00
iperov
8484060e01 Trainer: added option for all models
Enable autobackup? (y/n ?:help skip:%s) :
Autobackup model files with preview every hour for last 15 hours. Latest backup located in model/<>_autobackups/01

SAE: added option only for CUDA builds:
Enable gradient clipping? (y/n, ?:help skip:%s) :
Gradient clipping reduces chance of model collapse, sacrificing speed of training.
2019-06-20 10:42:55 +04:00
Jakob6174
ea1d59f620 Update ModelBase.py (#283)
Typo: 'NotImplementeError' --> 'NotImplementedError'
2019-06-19 13:02:19 +04:00
iperov
66a12a973a fix choosing preview image on options override 2019-05-14 17:00:25 +04:00
iperov
d6e8dde481 'sort by yaw' option now can be overriden each run 2019-05-14 09:33:53 +04:00
iperov
2a8dd788dc SAE: added option 'Pretrain the model?',
Pretrain the model with large amount of various faces. This technique may help to train the fake with overly different face shapes and light conditions of src/dst data. Face will be look more like a morphed. To reduce the morph effect, some model files will be initialized but not be updated after pretrain: LIAE: inter_AB.h5 DF: both decoders.h5. The longer you pretrain the model the more morphed face will look. After that, save and run the training again.
2019-05-01 19:55:27 +04:00
iperov
efb22ecce0 5 secs for override settings for colab 2019-04-30 07:32:15 +04:00
iperov
836693d64f added option 'Choose image for the preview history? (y/n skip:' 2019-04-27 10:03:54 +04:00
iperov
e1da9c56b4
SAE collapse fix (#245)
* test

* _

* _

* upd dev_poseest

* SAE: finally collapses are fixed

* fix batch size help
2019-04-24 09:38:26 +04:00
iperov
ea7ec74721 change help for batch size 2019-04-23 18:31:12 +04:00
iperov
3aef9a507b fix 2019-04-22 00:52:16 +04:00
iperov
44aa530fda multiple preview file support for colab 2019-04-22 00:49:50 +04:00
iperov
093ca4dba6 fix options in ModelBase.py 2019-04-21 21:08:45 +04:00
iperov
8e16f4fa1b fix 2019-04-20 16:10:58 +04:00
iperov
3ffdc50576 nothing interesting 2019-04-20 15:22:00 +04:00
iperov
5ac7e5d7f1 changed help message for pixel loss:
Pixel loss may help to enhance fine details and stabilize face color. Use it only if quality does not improve over time.

SAE:
previous SAE model will not work with this update.
Greatly decreased chance of model collapse.
Increased model accuracy.
Residual blocks now default and this option has been removed.
Improved 'learn mask'.
Added masked preview (switch by space key)

Converter:
fixed rct/lct in seamless mode
added mask mode (6) learned*FAN-prd*FAN-dst

added mask editor, its created for refining dataset for FANSeg model, and not for production, but you can spend your time and test it in regular fakes with face obstructions
2019-04-04 10:22:53 +04:00
iperov
3cf3bb786e rename samples to samplelib 2019-03-27 10:44:13 +04:00
iperov
070e938568 colab: final fix for preview filepath 2019-03-26 18:11:33 +04:00
iperov
e8a5a4bf10 _preview.jpg for colab 2019-03-26 17:58:29 +04:00
iperov
6241c8af41 preview file for colab 2019-03-26 17:14:59 +04:00
iperov
b03b147bae refactoring 2019-03-26 11:09:44 +04:00
iperov
131b2b5c79 after save loss string now shows averaged value since last save 2019-03-25 18:14:04 +04:00
iperov
a3df04999c removing trailing spaces 2019-03-19 23:53:27 +04:00
iperov
034ad3cce5 upd fan segmentator 2019-03-19 19:44:14 +04:00
iperov
5076feb90f SAE: revert back to sigmoid. Trainings must be restarted. 2019-03-16 09:01:11 +04:00
iperov
8da47fec13 fix ModelBase, nnlib 2019-03-13 20:53:59 +04:00
iperov
a9026ccb67 fix ModelBase, nnlib 2019-03-13 19:50:16 +04:00
iperov
58763756f5 SAE: removed simple_optimizer . Added optimizer mode for tensorflow only (NVIDIA cards), allows to train x2-x3 bigger networks with normal Adam optimizer, consuming VRAM and CPU power. 2019-03-13 11:54:17 +04:00
iperov
3c6775bae7 fix ModelBase.py 2019-03-12 23:22:58 +04:00
iperov
97b6fabaab change 'epoch' to 'iter',
added timestamp prefix to training string
2019-03-12 19:23:52 +04:00
iperov
46ff33bf89 SAE: dssim kernel size now depends on resolution 2019-03-12 09:49:40 +04:00
iperov
ee8dbcbc35 revert back Adam 2019-03-11 21:52:36 +04:00
iperov
e4637336ef added ability to save optimizers states which work with K.function,
added custom Adam that can save 'iterations' param
2019-03-11 18:23:01 +04:00
iperov
438213e97c manual extractor: increased FPS,
sort by final : now you can specify target number of images,
converter: fix seamless mask and exception,
huge refactoring
2019-02-28 11:56:31 +04:00