Spaces:
Running

aditya-rAj19 commited on
Commit
9e549b6
·
1 Parent(s): bb3e953

Confine scene grain to the parsed head instead of a box around it

Browse files

harmonize_to_scene built its mask from a rectangle around the face bbox, so the
grain meant for the GAN-smooth face and hair was sprayed over everything sharing
those bounds — background, bookshelves, clothing — dirtying the scene and
leaving the box's own feathered edge visible in the result.

It now parses the head/hair/neck shape (clamped to a generous head box so stray
specks elsewhere can't pick up grain) and feathers it narrowly, just enough to
fade at the hairline. Class 18 (hat) is included here only: the parser labels
part of the hair as hat, and dropping it left an ungrained hole in the top of
the head. _HEAD_CLASSES still excludes it for hair transfer, where it misfires.

Measured on a self-swap of the Library target (768x1024, CPU), where the output
should barely differ from the input: the mean pixel change from this step falls
from 6.46 to 0.33, and the masked region from roughly half the frame to 2.4%.
Background, shirt and shelves now come through untouched.

1 file changed +28 -8
core/head_swap.py+28-8