This commit implements changes based on the code review feedback for the recent face swap enhancement features. Key changes include: 1. **Error Handling for Color Transfer:** * Wrapped the `apply_color_transfer` call in `swap_face` (within `face_swapper.py`) in a try-except block. If color transfer fails, an error is logged, and the system falls back to using the uncorrected swapped face ROI, preventing pipeline crashes. 2. **GaussianBlur Kernel Size Validation:** * Added validation logic in `face_swapper.py` for `mouth_mask_blur_kernel_size` and `face_mask_blur_kernel_size`. * A helper function `_validate_kernel_size` ensures that kernel dimensions are positive odd integers. If invalid values are provided via global settings, a warning is logged, and the functions fall back to safe default kernel sizes (e.g., (9,9) for mouth, (5,5) for face). 3. **Configurable GFPGAN Upscale Factor:** * The `upscale` factor for `GFPGANer` in `face_enhancer.py` is now configurable via `getattr(modules.globals, 'gfpgan_upscale_factor', 2)`, allowing you to adjust this parameter. 4. **Clarification on Mouth Mask Blur Default:** * Added a comment in `face_swapper.py` explaining that the new default `(9,9)` for `mouth_mask_blur_kernel_size` is a deliberate performance/quality trade-off and that this setting is configurable. These changes improve the robustness, configurability, and clarity of the recently added features. |
||
---|---|---|
.. | ||
__init__.py | ||
core.py | ||
face_enhancer.py | ||
face_swapper.py |