# Task 4b for Hermes — Fix the LatentSync lower-face smear (mask/compositing)

(Continuation of the lip-sync task. Everything stays in the isolated `C:\latentsync\` — never touch `C:\ComfyUI`. STANDING CONSENT: you may create, edit, run, and back up any files under `C:\latentsync\` as needed; back up any file before you edit it; avoid destructive/delete commands — work in copies / fresh names instead.)

## Goal
Kill the lower-face smear in the lip-sync output so her mouth renders clean. Your own diagnosis was that it's NOT fp16 precision — it's the mask/compositing (paste-back) step. Confirm that, then fix it.

## Method — DIAGNOSE before you patch (don't guess the mask)
1. **Isolate the artifact's source first.** In a short 3s run, dump intermediates: (a) the raw generated mouth region straight out of the UNet/VAE (before paste-back), and (b) the same region AFTER the composite/restore. Compare them.
   - If the RAW generated mouth is already smeared → the artifact is generation-side (model/precision); report that.
   - If the raw mouth looks fine but the smear appears AFTER paste-back → it's the compositing, as suspected. Proceed to fix the mask.
2. **If it's compositing** (likely): in `latentsync\pipelines\lipsync_pipeline.py` — `paste_surrounding_pixels_back`, the mask blend (`decoded_latents*masks + pixel_values*(1-masks)`), `restore_video`, `AlignRestore.restore_img`:
   - Check whether the mask is inverted or far too broad for these faces.
   - Try a narrower, softer (feathered) lower-mouth mask so only the mouth region is replaced and the blend edges are gradual.
   - Back up the original file first.
3. **Rerun the 3s demo**, inspect a contact sheet / frames, iterate until the mouth is clean (moving, no smear, edges blend naturally).

## Constraints
- Fully isolated — confirm ComfyUI still renders when you're done (run `C:\malin\diagnose_render.py`, or have Jun send Malin a selfie).
- Back up any pipeline file before editing; avoid deletes.
- Time-box: if after a few focused iterations the mouth still won't come clean, STOP and report exactly what you found (which stage the artifact is in, what you tried, current quality). Voiceover stays the fallback. Don't spiral.

## Deliverable
Either: a clean-mouth 3s sample (report its path) + the exact change that fixed it — OR a precise isolation of where the smear originates (generation vs composite) and what you tried. Confirm ComfyUI render still works.
