default erode/blur values are 0.

new multiple faces detection log: https://i.imgur.com/0XObjsB.jpg
This commit is contained in:
Colombo 2020-02-01 18:50:43 +04:00
parent 1a0d7846a0
commit 9c07983c68
2 changed files with 31 additions and 11 deletions

View file

@ -691,43 +691,63 @@ def main (model_class_name=None,
def generator(): def generator():
for sample in io.progress_bar_generator( packed_samples, "Collecting alignments"): for sample in io.progress_bar_generator( packed_samples, "Collecting alignments"):
filepath = Path(sample.filename) filepath = Path(sample.filename)
yield DFLIMG.load(filepath, loader_func=lambda x: sample.read_raw_file() ) yield filepath, DFLIMG.load(filepath, loader_func=lambda x: sample.read_raw_file() )
else: else:
def generator(): def generator():
for filepath in io.progress_bar_generator( pathex.get_image_paths(aligned_path), "Collecting alignments"): for filepath in io.progress_bar_generator( pathex.get_image_paths(aligned_path), "Collecting alignments"):
filepath = Path(filepath) filepath = Path(filepath)
yield DFLIMG.load(filepath) yield filepath, DFLIMG.load(filepath)
alignments = {} alignments = {}
multiple_faces_detected = False multiple_faces_detected = False
for dflimg in generator(): for filepath, dflimg in generator():
if dflimg is None: if dflimg is None:
io.log_err ("%s is not a dfl image file" % (filepath.name) ) io.log_err ("%s is not a dfl image file" % (filepath.name) )
continue continue
source_filename = dflimg.get_source_filename() source_filename = dflimg.get_source_filename()
if source_filename is None or source_filename == "_": if source_filename is None:
continue continue
source_filename = Path(source_filename) source_filepath = Path(source_filename)
source_filename_stem = source_filename.stem source_filename_stem = source_filepath.stem
if source_filename_stem not in alignments.keys(): if source_filename_stem not in alignments.keys():
alignments[ source_filename_stem ] = [] alignments[ source_filename_stem ] = []
alignments_ar = alignments[ source_filename_stem ] alignments_ar = alignments[ source_filename_stem ]
alignments_ar.append (dflimg.get_source_landmarks()) alignments_ar.append ( (dflimg.get_source_landmarks(), filepath, source_filepath ) )
if len(alignments_ar) > 1: if len(alignments_ar) > 1:
multiple_faces_detected = True multiple_faces_detected = True
if multiple_faces_detected: if multiple_faces_detected:
io.log_info ("Warning: multiple faces detected. Strongly recommended to process them separately.") io.log_info ("")
io.log_info ("Warning: multiple faces detected. Only one alignment file should refer one source file.")
io.log_info ("")
for a_key in list(alignments.keys()):
a_ar = alignments[a_key]
if len(a_ar) > 1:
for _, filepath, source_filepath in a_ar:
io.log_info (f"alignment {filepath.name} refers to {source_filepath.name} ")
io.log_info ("")
if multiple_faces_detected:
io.log_info ("It is strongly recommended to process the faces separatelly.")
io.log_info ("Use 'recover original filename' to determine the exact duplicates.")
io.log_info ("")
frames = [ MergeSubprocessor.Frame( frame_info=FrameInfo(filepath=Path(p), landmarks_list=alignments.get(Path(p).stem, None))) for p in input_path_image_paths ] frames = [ MergeSubprocessor.Frame( frame_info=FrameInfo(filepath=Path(p),
landmarks_list=alignments.get(Path(p).stem, (None,) )[0]
)
)
for p in input_path_image_paths ]
if multiple_faces_detected: if multiple_faces_detected:
io.log_info ("Warning: multiple faces detected. Motion blur will not be used.") io.log_info ("Warning: multiple faces detected. Motion blur will not be used.")
io.log_info ("")
else: else:
s = 256 s = 256
local_pts = [ (s//2-1, s//2-1), (s//2-1,0) ] #center+up local_pts = [ (s//2-1, s//2-1), (s//2-1,0) ] #center+up

View file

@ -133,8 +133,8 @@ class MergerConfigMasked(MergerConfig):
masked_hist_match=True, masked_hist_match=True,
hist_match_threshold = 238, hist_match_threshold = 238,
mask_mode = 1, mask_mode = 1,
erode_mask_modifier = 100, erode_mask_modifier = 0,
blur_mask_modifier = 200, blur_mask_modifier = 0,
motion_blur_power = 0, motion_blur_power = 0,
output_face_scale = 0, output_face_scale = 0,
color_transfer_mode = ctm_str_dict['rct'], color_transfer_mode = ctm_str_dict['rct'],