mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 13:32:09 -07:00
_
This commit is contained in:
parent
565c131b97
commit
8969e80275
3 changed files with 15 additions and 7 deletions
|
@ -21,7 +21,7 @@ class Model(ModelBase):
|
|||
def onInitializeOptions(self, is_first_run, ask_override):
|
||||
default_face_type = 'f'
|
||||
if is_first_run:
|
||||
self.options['face_type'] = io.input_str ("Half or Full face? (h/f, ?:help skip:f) : ", default_face_type, ['h','f'], help_message="Half face has better resolution, but covers less area of cheeks.").lower()
|
||||
self.options['face_type'] = io.input_str ("Half or Full face? (h/f, ?:help skip:f) : ", default_face_type, ['h','f'], help_message="").lower()
|
||||
else:
|
||||
self.options['face_type'] = self.options.get('face_type', default_face_type)
|
||||
|
||||
|
@ -48,12 +48,12 @@ class Model(ModelBase):
|
|||
SampleGeneratorFace(self.training_data_src_path, debug=self.is_debug(), batch_size=self.batch_size,
|
||||
sample_process_options=SampleProcessor.Options(random_flip=True, motion_blur = [25, 1] ),
|
||||
output_sample_types=[ [f.WARPED_TRANSFORMED | face_type | f.MODE_BGR_SHUFFLE | f.OPT_APPLY_MOTION_BLUR, self.resolution],
|
||||
[f.WARPED_TRANSFORMED | face_type | f.MODE_M | f.FACE_MASK_FULL, self.resolution]
|
||||
[f.WARPED_TRANSFORMED | face_type | f.MODE_M | f.FACE_MASK_FULL, self.resolution],
|
||||
]),
|
||||
|
||||
SampleGeneratorFace(self.training_data_dst_path, debug=self.is_debug(), batch_size=self.batch_size,
|
||||
sample_process_options=SampleProcessor.Options(random_flip=True ),
|
||||
output_sample_types=[ [f.TRANSFORMED | face_type | f.MODE_BGR_SHUFFLE, self.resolution]
|
||||
output_sample_types=[ [f.TRANSFORMED | face_type | f.MODE_BGR_SHUFFLE, self.resolution],
|
||||
])
|
||||
])
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from samplelib import SampleType, SampleProcessor, SampleLoader, SampleGenerator
|
|||
'''
|
||||
arg
|
||||
output_sample_types = [
|
||||
[SampleProcessor.TypeFlags, size, (optional)random_sub_size] ,
|
||||
[SampleProcessor.TypeFlags, size, (optional) {} opts ] ,
|
||||
...
|
||||
]
|
||||
'''
|
||||
|
|
|
@ -32,6 +32,8 @@ class SampleProcessor(object):
|
|||
MODE_M = 0x00080000, #mask only
|
||||
MODE_BGR_SHUFFLE = 0x00100000, #BGR shuffle
|
||||
|
||||
|
||||
|
||||
OPT_APPLY_MOTION_BLUR = 0x10000000,
|
||||
|
||||
class Options(object):
|
||||
|
@ -79,7 +81,10 @@ class SampleProcessor(object):
|
|||
for sample_type in output_sample_types:
|
||||
f = sample_type[0]
|
||||
size = 0 if len (sample_type) < 2 else sample_type[1]
|
||||
random_sub_size = 0 if len (sample_type) < 3 else min( sample_type[2] , size)
|
||||
opts = {} if len (sample_type) < 3 else sample_type[2]
|
||||
|
||||
random_sub_size = opts.get('random_sub_size', 0)
|
||||
normalize_std_dev = opts.get('normalize_std_dev', False)
|
||||
|
||||
if f & SPTF.SOURCE != 0:
|
||||
img_type = 0
|
||||
|
@ -221,6 +226,9 @@ class SampleProcessor(object):
|
|||
img_bgr = img[...,0:3]
|
||||
img_mask = img[...,3:4]
|
||||
|
||||
if normalize_std_dev:
|
||||
img_bgr = (img_bgr - img_bgr.mean( (0,1)) ) / img_bgr.std( (0,1) )
|
||||
|
||||
if f & SPTF.MODE_BGR != 0:
|
||||
img = img_bgr
|
||||
elif f & SPTF.MODE_BGR_SHUFFLE != 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue