Optimizes webcam performance for face swapping by introducing
Nth-frame full face detection and using a KCF tracker for
intermediate frames in modules/processors/frame/face_swapper.py.
Key changes:
- Full face analysis (get_one_face) now runs every N frames (default 3)
or when tracking is lost in the process_frame function (for single
face mode).
- For intermediate frames, a KCF tracker updates the target face bounding
box, and keypoints are estimated by translating the last known good
keypoints.
- The actual face swap (inswapper model) still runs on every frame if a
face (either detected or tracked) is available.
- Experimental tracking logic added to _process_live_target_v2 for
map_faces=True in live mode (non-many_faces path).
- Added robustness:
- None checks for landmarks in mouth_mask and create_face_mask
functions, with fallbacks for create_face_mask.
- Division-by-zero check in apply_color_transfer.
- Reset tracker state in process_video for new video files.
This aims to significantly improve FPS by reducing the frequency of
costly full face analysis, while still providing a continuous swap.
Mouth masking will be less effective on tracked intermediate frames
due to the absence of full landmark data.