Commit graph

283 commits

Author SHA1 Message Date
Colombo
45582d129d added XSeg model.
with XSeg model you can train your own mask segmentator of dst(and src) faces
that will be used in merger for whole_face.

Instead of using a pretrained model (which does not exist),
you control which part of faces should be masked.

Workflow is not easy, but at the moment it is the best solution
for obtaining the best quality of whole_face's deepfakes using minimum effort
without rotoscoping in AfterEffects.

new scripts:
	XSeg) data_dst edit.bat
	XSeg) data_dst merge.bat
	XSeg) data_dst split.bat
	XSeg) data_src edit.bat
	XSeg) data_src merge.bat
	XSeg) data_src split.bat
	XSeg) train.bat

Usage:
	unpack dst faceset if packed

	run XSeg) data_dst split.bat
		this scripts extracts (previously saved) .json data from jpg faces to use in label tool.

	run XSeg) data_dst edit.bat
		new tool 'labelme' is used

		use polygon (CTRL-N) to mask the face
			name polygon "1" (one symbol) as include polygon
			name polygon "0" (one symbol) as exclude polygon

			'exclude polygons' will be applied after all 'include polygons'

		Hot keys:
		ctrl-N			create polygon
		ctrl-J			edit polygon
		A/D 			navigate between frames
		ctrl + mousewheel 	image zoom
		mousewheel		vertical scroll
		alt+mousewheel		horizontal scroll

		repeat for 10/50/100 faces,
			you don't need to mask every frame of dst,
			only frames where the face is different significantly,
			for example:
				closed eyes
				changed head direction
				changed light
			the more various faces you mask, the more quality you will get

			Start masking from the upper left area and follow the clockwise direction.
			Keep the same logic of masking for all frames, for example:
				the same approximated jaw line of the side faces, where the jaw is not visible
				the same hair line
			Mask the obstructions using polygon with name "0".

	run XSeg) data_dst merge.bat
		this script merges .json data of polygons into jpg faces,
		therefore faceset can be sorted or packed as usual.

	run XSeg) train.bat
		train the model

		Check the faces of 'XSeg dst faces' preview.

		if some faces have wrong or glitchy mask, then repeat steps:
			split
			run edit
			find these glitchy faces and mask them
			merge
			train further or restart training from scratch

Restart training of XSeg model is only possible by deleting all 'model\XSeg_*' files.

If you want to get the mask of the predicted face in merger,
you should repeat the same steps for src faceset.

New mask modes available in merger for whole_face:

XSeg-prd	  - XSeg mask of predicted face	 -> faces from src faceset should be labeled
XSeg-dst	  - XSeg mask of dst face        -> faces from dst faceset should be labeled
XSeg-prd*XSeg-dst - the smallest area of both

if workspace\model folder contains trained XSeg model, then merger will use it,
otherwise you will get transparent mask by using XSeg-* modes.

Some screenshots:
label tool: https://i.imgur.com/aY6QGw1.jpg
trainer   : https://i.imgur.com/NM1Kn3s.jpg
merger    : https://i.imgur.com/glUzFQ8.jpg

example of the fake using 13 segmented dst faces
          : https://i.imgur.com/wmvyizU.gifv
2020-03-15 15:12:44 +04:00
Colombo
dde856499d saehd: removed liaech 2020-03-13 13:04:26 +04:00
Colombo
61472cdaf7 global refactoring and fixes,
removed support of extracted(aligned) PNG faces. Use old builds to convert from PNG to JPG.

fanseg model file in facelib/ is renamed
2020-03-13 08:09:00 +04:00
Colombo
ba58621361 SAEHD: removed option learn_mask, it is now enabled by default 2020-03-10 10:36:08 +04:00
Colombo
b0b9072981 added XSeg model 2020-03-09 13:09:46 +04:00
Colombo
9eb15065f9 _ 2020-03-09 10:15:29 +04:00
Colombo
d731930537 fixes 2020-03-09 00:18:01 +04:00
Colombo
121c0cfc0f FANSeg : reverting to use it the same as in DFL 1.0 2020-03-08 22:25:11 +04:00
Colombo
22b0865455 upd FANSeg 2020-03-08 10:47:04 +04:00
Colombo
18d93376fc update FANSeg 2020-03-08 10:34:48 +04:00
Colombo
143792fd31 added fanseg for future WF segmentation model 2020-03-08 00:49:12 +04:00
Colombo
3b6ad4abf9 refactoring 2020-03-07 20:51:54 +04:00
Colombo
d6a685887f fix nick 2020-03-07 19:20:07 +04:00
Colombo
45270f3fb5 SAEHD:
added new experimental arhi
'liaech' - made by @chervoniy. Based on liae, but produces more src-like face.
2020-03-07 16:06:10 +04:00
Colombo
ada60ccefe code refactoring,
lr_dropout is now disabled in pretraining mode
changed help message for lr_dropout and random_warp
2020-03-07 13:59:47 +04:00
Colombo
302d23a612 refactoring 2020-03-03 22:20:15 +04:00
Colombo
757ec77e44 refactoring 2020-03-01 19:09:50 +04:00
Colombo
f88c45d338 fix saehd for multi gpu 2020-02-27 23:06:06 +04:00
Colombo
74999ce7ee SAEHD:
'models_opt_on_gpu' option is now available for multigpus (before only for 1 gpu)
max resolution is now 512
2020-02-27 16:21:32 +04:00
Colombo
30c93a9bdb fix 2020-02-27 11:41:06 +04:00
Colombo
c7ab9653c5 new optimized training:
for every batch_size*16 samples,
model collects the samples with the highest error and learns them again
therefore hard samples will be trained more often
2020-02-27 11:19:53 +04:00
Colombo
a5783df546 fix autobackup_hour 2020-02-27 11:13:45 +04:00
Colombo
a1cc297cef SAEHD: fix hd arhis 2020-02-25 21:58:05 +04:00
Colombo
58deb2bed1 enable pretrain option for whole_face type 2020-02-23 20:49:30 +04:00
Colombo
f1d115b63b added experimental face type 'whole_face'
Basic usage instruction: https://i.imgur.com/w7LkId2.jpg

	'whole_face' requires skill in Adobe After Effects.

	For using whole_face you have to extract whole_face's by using
	4) data_src extract whole_face
	and
	5) data_dst extract whole_face
	Images will be extracted in 512 resolution, so they can be used for regular full_face's and half_face's.

	'whole_face' covers whole area of face include forehead in training square,
	but training mask is still 'full_face'
	therefore it requires manual final masking and composing in Adobe After Effects.

added option 'masked_training'
	This option is available only for 'whole_face' type.
	Default is ON.
	Masked training clips training area to full_face mask,
	thus network will train the faces properly.
	When the face is trained enough, disable this option to train all area of the frame.
	Merge with 'raw-rgb' mode, then use Adobe After Effects to manually mask, tune color, and compose whole face include forehead.
2020-02-21 16:21:04 +04:00
Colombo
778fb94246 saehd change face_style help 2020-02-20 20:56:02 +04:00
Colombo
c052ee7d60 SAEHD : change help message for eyes_prio : Helps to fix eye problems during training like "alien eyes" and wrong eyes direction ( especially on HD architectures ) by forcing the neural network to train eyes with higher priority. before/after 2020-02-20 08:29:37 +04:00
Colombo
7a9cd6379f bug fixes 2020-02-19 15:27:22 +04:00
Colombo
f4b163d721 fix 2020-02-18 19:34:23 +04:00
Colombo
d4335b5fa5 fix 2020-02-18 19:16:44 +04:00
Colombo
9598ba0141 SAEHD:
added option Eyes priority (y/n)

	fix eye problems during training  ( especially on HD architectures )
	by forcing the neural network to train eyes with higher priority
	before/after https://i.imgur.com/YQHOuSR.jpg

	It does not guarantee the right eye direction.
2020-02-18 14:30:07 +04:00
Colombo
4850ef4965 autobackup hour 2020-02-03 06:37:54 +04:00
Colombo
5620763ccf "Enable autobackup" option is replaced by
"Autobackup every N hour" 0..24 (default 0 disabled), Autobackup model files with preview every N hour
2020-02-02 20:53:18 +04:00
Colombo
05f32d678d SAEHD: default archi is now 'df' 2020-01-31 22:42:25 +04:00
Colombo
9fd49ee3f0 removed use_float16 option
fix multigpu training
2020-01-30 07:35:33 +04:00
Colombo
5fe5fa131c SampleProcessor.py : refactoring and gen mask struct 2020-01-29 18:08:54 +04:00
Colombo
0251eb3490 MultiGPU training:
speed is significantly increased.
fixed CUDNN_STREAM errors.

Trainer: added key 'b' : creates a backup even if the autobackup is disabled.
2020-01-29 10:55:51 +04:00
Colombo
a6d72b620d fix asking options 2020-01-29 02:40:57 +04:00
Colombo
1fd4a25882 use_float16 update description 2020-01-28 15:22:03 +04:00
Colombo
01800010d4 options order fix 2020-01-28 15:17:11 +04:00
Colombo
9c6ca24642 fix update preview samples after disable pretrain 2020-01-28 13:32:01 +04:00
Colombo
7386a9d6fd optimized face sample generator, CPU load is significantly reduced
SAEHD:

added new option
GAN power 0.0 .. 10.0
	Train the network in Generative Adversarial manner.
	Forces the neural network to learn small details of the face.
	You can enable/disable this option at any time,
	but better to enable it when the network is trained enough.
	Typical value is 1.0
	GAN power with pretrain mode will not work.

Example of enabling GAN on 81k iters +5k iters
https://i.imgur.com/OdXHLhU.jpg
https://i.imgur.com/CYAJmJx.jpg

dfhd: default Decoder dimensions are now 48
the preview for 256 res is now correctly displayed

fixed model naming/renaming/removing

Improvements for those involved in post-processing in AfterEffects:

Codec is reverted back to x264 in order to properly use in AfterEffects and video players.

Merger now always outputs the mask to workspace\data_dst\merged_mask

removed raw modes except raw-rgb
raw-rgb mode now outputs selected face mask_mode (before square mask)

'export alpha mask' button is replaced by 'show alpha mask'.
You can view the alpha mask without recompute the frames.

8) 'merged *.bat' now also output 'result_mask.' video file.
8) 'merged lossless' now uses x264 lossless codec (before PNG codec)
result_mask video file is always lossless.

Thus you can use result_mask video file as mask layer in the AfterEffects.
2020-01-28 12:24:45 +04:00
Colombo
17337ea8f8 fixed model renaming/deleting 2020-01-26 14:49:37 +04:00
Colombo
c485e1718a fixes 2020-01-26 12:56:21 +04:00
Colombo
76ca79216e Upgraded to TF version 1.13.2
Removed the wait at first launch for most graphics cards.

Increased speed of training by 10-20%, but you have to retrain all models from scratch.

SAEHD:

added option 'use float16'
	Experimental option. Reduces the model size by half.
	Increases the speed of training.
	Decreases the accuracy of the model.
	The model may collapse or not train.
	Model may not learn the mask in large resolutions.

true_face_training option is replaced by
"True face power". 0.0000 .. 1.0
Experimental option. Discriminates the result face to be more like the src face. Higher value - stronger discrimination.
Comparison - https://i.imgur.com/czScS9q.png
2020-01-25 21:58:19 +04:00
Colombo
f1a3150ce9 1 2020-01-22 22:14:31 +04:00
Colombo
60804ca3ba 1 2020-01-22 13:41:05 +04:00
Colombo
beed145d29 1 2020-01-22 10:29:17 +04:00
Colombo
9797a70fd3 1 2020-01-21 21:05:29 +04:00
Colombo
38b85108b3 DFL-2.0 initial branch commit 2020-01-21 18:43:39 +04:00