diff --git a/models/Model_DEV_FANSEG/Model.py b/models/Model_DEV_FANSEG/Model.py index 5e84c08..2233947 100644 --- a/models/Model_DEV_FANSEG/Model.py +++ b/models/Model_DEV_FANSEG/Model.py @@ -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], ]) ]) @@ -71,8 +71,8 @@ class Model(ModelBase): #override def onGetPreview(self, sample): - test_A = sample[0][0][0:4] #first 4 samples - test_B = sample[1][0][0:4] #first 4 samples + test_A = sample[0][0][0:4] #first 4 samples + test_B = sample[1][0][0:4] #first 4 samples mAA = self.fan_seg.extract(test_A) mBB = self.fan_seg.extract(test_B) diff --git a/samplelib/SampleGeneratorFace.py b/samplelib/SampleGeneratorFace.py index 3fcc530..59f8a58 100644 --- a/samplelib/SampleGeneratorFace.py +++ b/samplelib/SampleGeneratorFace.py @@ -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 ] , ... ] ''' diff --git a/samplelib/SampleProcessor.py b/samplelib/SampleProcessor.py index 3da41a0..39d953f 100644 --- a/samplelib/SampleProcessor.py +++ b/samplelib/SampleProcessor.py @@ -31,6 +31,8 @@ class SampleProcessor(object): MODE_GGG = 0x00040000, #3xGrayscale MODE_M = 0x00080000, #mask only MODE_BGR_SHUFFLE = 0x00100000, #BGR shuffle + + OPT_APPLY_MOTION_BLUR = 0x10000000, @@ -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 @@ -220,6 +225,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