Commit graph

164 commits

Author SHA1 Message Date
iperov
b9c9e7cffd fix depth_to_space for tf2.4.0. Removing compute_output_shape in leras, because it uses CPU device, which does not support all ops. 2020-12-11 11:28:33 +04:00
Colombo
bb432b21f9 . 2020-11-25 12:19:43 +04:00
Colombo
c516454566 fix rmsprop 2020-11-18 13:59:14 +04:00
Colombo
874a7eba18 1 2020-11-18 13:41:19 +04:00
Colombo
1adad3ece6 fix RMSprop.py 2020-11-18 13:38:27 +04:00
Colombo
0eb7e06ac1 upgrade to tf 2.4.0rc1 2020-11-13 17:00:07 +04:00
Colombo
dd21880ecd fix 2020-07-16 23:39:56 +04:00
Colombo
e8b04053e4 SAEHD:
Changed help for “Learning rate dropout” option:

When the face is trained enough, you can enable this option to get extra sharpness and reduce subpixel shake for less amount of iterations.

Enabled it before “disable random warp” and before GAN. n disabled. y enabled

cpu enabled on CPU. This allows not to use extra VRAM, sacrificing 20% time of iteration.

 Changed help for GAN option:

Train the network in Generative Adversarial manner.

Forces the neural network to learn small details of the face.

Enable it only when the face is trained enough and don't disable.

Typical value is 0.1

improved GAN. Now it produces better skin detail, less patterned aggressive artifacts, works faster.
https://i.imgur.com/Nbh3mw1.png
2020-07-16 22:19:17 +04:00
Colombo
aacd29269a fix 2020-07-16 22:11:23 +04:00
Colombo
5a40f537cc . 2020-07-04 07:58:53 +04:00
Colombo
9a540e644c upd leras ops 2020-07-03 19:32:14 +04:00
Colombo
b0ad36de94 upd cv2ex 2020-07-03 19:30:52 +04:00
Colombo
3283dce96a interact: change to waitKeyEx 2020-07-03 18:43:18 +04:00
Colombo
770da74a9b fix cv2.resize interpolation 2020-07-03 18:40:35 +04:00
Colombo
4ce4997d1a fix 2020-07-03 15:19:12 +04:00
Colombo
e6aa996814 leras: add ability to save sub layers in a dict 2020-07-01 22:17:35 +04:00
Colombo
b6dd482e05 . 2020-06-27 19:08:14 +04:00
Colombo
d78ec338c6 fix Subprocessor now writes an error if it fails to process the data 2020-06-24 11:44:58 +04:00
Colombo
ddb6bcf416 fix 2020-06-24 11:44:24 +04:00
Colombo
29b1050637 Sorter: improved sort by blur, and sort by best faces 2020-06-23 21:02:38 +04:00
Colombo
2b8e8f0554 . 2020-06-20 22:05:30 +04:00
Colombo
05606b5e15 Subprocessor: now should write an error if failed to start 2020-06-19 14:20:22 +04:00
Colombo
0c2e1c3944 SAEHD:
Maximum resolution is increased to 640.

‘hd’ archi is removed. ‘hd’ was experimental archi created to remove subpixel shake, but ‘lr_dropout’ and ‘disable random warping’ do that better.

‘uhd’ is renamed to ‘-u’
dfuhd and liaeuhd will be automatically renamed to df-u and liae-u in existing models.

Added new experimental archi (key -d) which doubles the resolution using the same computation cost.
It is mean same configs will be x2 faster, or for example you can set 448 resolution and it will train as 224.
Strongly recommended not to train from scratch and use pretrained models.

New archi naming:
'df' keeps more identity-preserved face.
'liae' can fix overly different face shapes.
'-u' increased likeness of the face.
'-d' (experimental) doubling the resolution using the same computation cost
Examples: df, liae, df-d, df-ud, liae-ud, ...

Improved GAN training (GAN_power option).  It was used for dst model, but actually we don’t need it for dst.
Instead, a second src GAN model with x2 smaller patch size was added, so the overall quality for hi-res models should be higher.

Added option ‘Uniform yaw distribution of samples (y/n)’:
	Helps to fix blurry side faces due to small amount of them in the faceset.

Quick96:
	Now based on df-ud archi and 20% faster.

XSeg trainer:
	Improved sample generator.
Now it randomly adds the background from other samples.
Result is reduced chance of random mask noise on the area outside the face.
Now you can specify ‘batch_size’ in range 2-16.

Reduced size of samples with applied XSeg mask. Thus size of packed samples with applied xseg mask is also reduced.
2020-06-19 09:45:55 +04:00
Colombo
af98407f06 SAEHD: lr_dropout now can be ‘n’, ‘y’, ‘cpu’. ‘n’ and ’y’ are the same as before.
‘cpu’ mean enabled on CPU. This allows not to use extra VRAM, sacrificing 20% time of iteration.

SAEHD: resolution >= 256 now has second dssim loss function
2020-06-08 14:18:33 +04:00
Colombo
4acaf08ebf fix 2020-06-08 14:07:47 +04:00
Colombo
cfd7803e0d leras : DepthwiseConv2D 2020-06-07 20:59:12 +04:00
Colombo
85ede1a7e7 . 2020-06-07 12:26:23 +04:00
Colombo
ddf7363eda remove unused code 2020-06-06 20:02:21 +04:00
Colombo
235315dd70 fix 2020-06-06 19:52:07 +04:00
Colombo
1e003170bd reduced chance of "The paging file is too small for this operation to complete." 2020-06-06 19:38:11 +04:00
Colombo
0c18b1f011 changed uhd arhi: you have to retrain uhd arhis from scratch. 2020-05-06 19:21:23 +04:00
Colombo
baff59e421 . 2020-04-15 22:58:59 +04:00
Colombo
6bbc607312 color transfer sot : optimization 2020-04-15 18:13:03 +04:00
Colombo
935d940ace fix 2020-04-07 22:06:32 +04:00
Colombo
f821ab350f fix 2020-04-06 19:06:37 +04:00
Colombo
afdb1ef85d fix for 16+ CPU 2020-04-06 18:42:38 +04:00
Colombo
33b0aadb4e Decreased amount of RAM used by Sample Generator. 2020-04-05 13:52:32 +04:00
Colombo
2fe86faf01 fix Win10 input dialog 2020-04-02 10:27:39 +04:00
Colombo
6d3607a13d New script:
5.XSeg) data_dst/src mask for XSeg trainer - fetch.bat
Copies faces containing XSeg polygons to aligned_xseg\ dir.
Useful only if you want to collect labeled faces and reuse them in other fakes.

Now you can use trained XSeg mask in the SAEHD training process.
It’s mean default ‘full_face’ mask obtained from landmarks will be replaced with the mask obtained from the trained XSeg model.
use
5.XSeg.optional) trained mask for data_dst/data_src - apply.bat
5.XSeg.optional) trained mask for data_dst/data_src - remove.bat

Normally you don’t need it. You can use it, if you want to use ‘face_style’ and ‘bg_style’ with obstructions.

XSeg trainer : now you can choose type of face
XSeg trainer : now you can restart training in “override settings”
Merger: XSeg-* modes now can be used with all types of faces.

Therefore old MaskEditor, FANSEG models, and FAN-x modes have been removed,
because the new XSeg solution is better, simpler and more convenient, which costs only 1 hour of manual masking for regular deepfake.
2020-03-30 14:00:40 +04:00
Colombo
d1a5639e90 XSegEditor: fix bugs 2020-03-27 19:08:01 +04:00
Colombo
ca9138d6b7 XSegEditor: changed layout, added current filename 2020-03-27 00:11:36 +04:00
Colombo
8ad2a5373e fix Exception("nn devices are not initialized. Run initialize_main_env() in main process.") 2020-03-24 22:06:10 +04:00
Colombo
01d81674fd added new XSegEditor !
here new whole_face + XSeg workflow:

with XSeg model you can train your own mask segmentator for dst(and/or src) faces
that will be used by the merger for whole_face.

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

new scripts:
	5.XSeg) data_dst edit masks.bat
	5.XSeg) data_src edit masks.bat
	5.XSeg) train.bat

Usage:
	unpack dst faceset if packed

	run 5.XSeg) data_dst edit masks.bat

	Read tooltips on the buttons (en/ru/zn languages are supported)

	mask the face using include or exclude polygon mode.

	repeat for 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 exclude polygon mode.

	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:
			run edit
			find these glitchy faces and mask them
			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 (XSeg-prd mode) 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:
XSegEditor: https://i.imgur.com/7Bk4RRV.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-24 12:15:31 +04:00
Colombo
eddebedcf6 SAEHD: added 'dfuhd' and 'liaeuhd' archi 2020-03-23 22:01:44 +04:00
Colombo
a9b23e9851 _ 2020-03-21 00:01:53 +04:00
Colombo
3fa93da5e7 upd 2020-03-20 11:37:42 +04:00
Colombo
4c24f9d41c _ 2020-03-19 13:29:33 +04:00
Colombo
f3b4658810 fixes 2020-03-16 22:40:55 +04:00
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
7c89077321 update core.imagelib 2020-03-13 19:27:13 +04:00