mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 22:34:25 -07:00
re-enable clipping, enable preserve paper
This commit is contained in:
parent
c24d6a87ea
commit
0e68ed0056
2 changed files with 13 additions and 11 deletions
|
@ -76,7 +76,7 @@ def reinhard_color_transfer(target, source, clip=False, preserve_paper=False, ta
|
||||||
a += aMeanSrc
|
a += aMeanSrc
|
||||||
b += bMeanSrc
|
b += bMeanSrc
|
||||||
|
|
||||||
# clip/scale the pixel intensities to [0, 255] if they fall
|
# clip/scale the pixel intensities to [0, 1] if they fall
|
||||||
# outside this range
|
# outside this range
|
||||||
l = _scale_array(l, clip=clip)
|
l = _scale_array(l, clip=clip)
|
||||||
a = _scale_array(a, clip=clip)
|
a = _scale_array(a, clip=clip)
|
||||||
|
@ -156,15 +156,15 @@ def _scale_array(arr, clip=True):
|
||||||
if clip:
|
if clip:
|
||||||
return np.clip(arr, 0, 1)
|
return np.clip(arr, 0, 1)
|
||||||
|
|
||||||
return (arr - np.min(arr)) / np.ptp(arr)
|
# return (arr - np.min(arr)) / np.ptp(arr)
|
||||||
# mn = arr.min()
|
mn = arr.min()
|
||||||
# mx = arr.max()
|
mx = arr.max()
|
||||||
# scale_range = (max([mn, 0]), min([mx, 1]))
|
scale_range = (max([mn, 0]), min([mx, 1]))
|
||||||
#
|
|
||||||
# if mn < scale_range[0] or mx > scale_range[1]:
|
if mn < scale_range[0] or mx > scale_range[1]:
|
||||||
# return (scale_range[1] - scale_range[0]) * (arr - mn) / (mx - mn) + scale_range[0]
|
return (scale_range[1] - scale_range[0]) * (arr - mn) / (mx - mn) + scale_range[0]
|
||||||
#
|
|
||||||
# return arr
|
return arr
|
||||||
|
|
||||||
|
|
||||||
def channel_hist_match(source, template, hist_match_threshold=255, mask=None):
|
def channel_hist_match(source, template, hist_match_threshold=255, mask=None):
|
||||||
|
|
|
@ -235,13 +235,15 @@ class SampleProcessor(object):
|
||||||
img_bgr = imagelib.linear_color_transfer(img_bgr, ct_sample_bgr)
|
img_bgr = imagelib.linear_color_transfer(img_bgr, ct_sample_bgr)
|
||||||
|
|
||||||
elif apply_ct == ColorTransferMode.RCT:
|
elif apply_ct == ColorTransferMode.RCT:
|
||||||
img_bgr = imagelib.reinhard_color_transfer(img_bgr, ct_sample_bgr)
|
img_bgr = imagelib.reinhard_color_transfer(img_bgr, ct_sample_bgr, clip=True, preserve_paper=True)
|
||||||
|
|
||||||
elif apply_ct == ColorTransferMode.RCT_MASKED and ct_sample_mask is None:
|
elif apply_ct == ColorTransferMode.RCT_MASKED and ct_sample_mask is None:
|
||||||
ct_sample_mask = ct_sample.load_fanseg_mask() or \
|
ct_sample_mask = ct_sample.load_fanseg_mask() or \
|
||||||
LandmarksProcessor.get_image_hull_mask(ct_sample_bgr.shape, ct_sample.landmarks)
|
LandmarksProcessor.get_image_hull_mask(ct_sample_bgr.shape, ct_sample.landmarks)
|
||||||
img_bgr = imagelib.reinhard_color_transfer(img_bgr,
|
img_bgr = imagelib.reinhard_color_transfer(img_bgr,
|
||||||
ct_sample_bgr,
|
ct_sample_bgr,
|
||||||
|
clip=True,
|
||||||
|
preserve_paper=True,
|
||||||
target_mask=img_mask,
|
target_mask=img_mask,
|
||||||
source_mask=ct_sample_mask)
|
source_mask=ct_sample_mask)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue