Spaces:
Running

aditya-rAj19 commited on
Commit
27bac33
·
1 Parent(s): 4b38f72

Fix scene-harmonisation regressions: quality scores, skin-tone reversal, long-hair gap

Browse files

Three bugs in the harmonise pass (step 8) and its wiring:

1. Grain was injected BEFORE compute_quality_score ran on the same image, so
the deliberate noise fed straight into the naturalness noise-penalty and the
blend discontinuity term — the "make it look photographed" step was lowering
the app's own reported quality on every swap. Quality + alignment are now
scored first; harmonise still runs last before the output is encoded, so the
grain survives into both the preview and the 4K download.

2. The colour cast sampled scene_mean over the WHOLE target frame, which still
contains the original target face (target is never overwritten by the swap).
That dragged the head's colour back toward the tone of the face it replaced,
partially undoing match_skin_to_source one step earlier. It now samples only
outside the head mask, and works in LAB with the same darken-only L rule as
_match_lighting, so a bright background can't wash hair/skin to grey/silver.

3. The mask reached only 1.2x face-height below the chin while swap_hair places
hair as far as 5.0x, so the lower half of long transplanted hair never got
grained and kept the GAN-smooth look. Extended to 3.0x.

Both internal except blocks swallowed errors silently; they now log like every
other function in the file.

2 files changed +45 -21
Files changed (2)
core/head_swap.py+32-12
web_app.py+13-9