Merge branch 'master' into feat/ping-pong

This commit is contained in:
ShumptonLang 2019-08-13 15:50:52 -06:00 committed by GitHub
commit 45adef6c08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 25 deletions

View file

@ -135,7 +135,7 @@ class ExtractSubprocessor(Subprocessor):
if filename_path.suffix == '.png':
src_dflimg = DFLPNG.load ( str(filename_path) )
if filename_path.suffix == '.jpg':
src_dflimg = DFLPNG.load ( str(filename_path) )
src_dflimg = DFLJPG.load ( str(filename_path) )
if 'rects' in self.type:
if min(w,h) < 128:
@ -242,15 +242,27 @@ class ExtractSubprocessor(Subprocessor):
if self.debug_dir is not None:
LandmarksProcessor.draw_rect_landmarks (debug_image, rect, image_landmarks, self.image_size, self.face_type, transparent_mask=True)
if src_dflimg is not None and filename_path.suffix == '.jpg':
#if extracting from dflimg and jpg copy it in order not to lose quality
output_file = str(self.final_output_path / filename_path.name)
if str(filename_path) != str(output_file):
shutil.copy ( str(filename_path), str(output_file) )
else:
output_file = '{}_{}{}'.format(str(self.final_output_path / filename_path.stem), str(face_idx), '.png')
cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_PNG_COMPRESSION), 0] )
if filename_path.suffix == '.jpg':
# if extracting from dflimg and jpg copy it in order not to lose quality
output_file = '{}_{}{}'.format(str(self.final_output_path / filename_path.stem),
str(face_idx), '.jpg')
if str(filename_path) != str(output_file):
shutil.copy(str(filename_path), str(output_file))
cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_JPEG_QUALITY), 95])
DFLJPG.embed_data(output_file, face_type=FaceType.toString(self.face_type),
landmarks=face_image_landmarks.tolist(),
source_filename=filename_path.name,
source_rect=rect,
source_landmarks=image_landmarks.tolist(),
image_to_face_mat=image_to_face_mat,
pitch_yaw_roll=data.pitch_yaw_roll
)
else:
output_file = '{}_{}{}'.format(str(self.final_output_path / filename_path.stem),
str(face_idx), '.png')
cv2_imwrite(output_file, face_image, [int(cv2.IMWRITE_PNG_COMPRESSION), 3])
DFLPNG.embed_data(output_file, face_type=FaceType.toString(self.face_type),
landmarks=face_image_landmarks.tolist(),
source_filename=filename_path.name,

View file

@ -166,14 +166,10 @@ class ModelBase(object):
else:
self.options['sort_by_yaw'] = self.options.get('sort_by_yaw', False)
if ask_random_flip:
if (self.iter == 0):
self.options['random_flip'] = io.input_bool("Flip faces randomly? (y/n ?:help skip:y) : ", True,
help_message="Predicted face will look more naturally"
" without this option, but src faceset should"
" cover all face directions as dst faceset.")
else:
self.options['random_flip'] = self.options.get('random_flip', True)
if ask_override:
self.options['random_flip'] = io.input_bool("Flip faces randomly? (y/n ?:help skip:y) : ", True, help_message="Predicted face will look more naturally without this option, but src faceset should cover all face directions as dst faceset.")
if ask_src_scale_mod:
if self.iter == 0: