Spaces:
Running

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

Keep the original photo's background instead of downscaling and interpolating it

Browse files

The pipeline resizes the target to the working resolution (1024 on CPU) so the
models stay affordable, then upscales the whole frame 4x for the download. For a
1086x1448 location photo that means everything — including the background and
body, which the swap never touches — is halved in detail and then interpolated
back up.

The result is now composited back onto the untouched full-resolution target,
pasting only the region the pipeline actually changed. The mask comes from a
diff against the working-resolution target rather than a parsed head shape, so
changes outside the head are carried over too: match_skin_to_source also
recolours neck, arms and hands, and a head-only mask would silently drop that.

Measured end-to-end on the Library target, in regions the swap never touches:
background sharpness goes from ~34% of the original to 100% (bottom edge 97.6%),
and the delivered image is now 1086x1448 native rather than 768x1024, so the 4x
download is 4344x5792 instead of 3072x4096. No seam at the composite boundary.

14 tests pass.

2 files changed +61 -1
Files changed (2)
utils/image_io.py+47
web_app.py+14-1