fix: Address review feedback for stability and code quality

This commit incorporates fixes based on a detailed code review, addressing several critical and code quality issues to improve application stability and maintainability.

Key changes include:

modules/hair_segmenter.py:
- Removed a redundant model initialization check to streamline logic.

modules/processors/frame/face_swapper.py:
- Added try-except error handling around calls to segment_hair(), create_face_mask(), and apply_color_transfer() to prevent crashes during the hair swapping process and allow for graceful fallbacks.
- Ensured safer access to the global 'enable_hair_swapping' flag by using getattr(), providing a default value to prevent AttributeErrors.
- Verified that a previously flagged redundant image read in process_image() was already addressed.

modules/ui.py:
- Corrected the function call signature for the Face Enhancer's process_frame_v2 method within the webcam preview when map_faces mode is active.
- Made the conditional check for source image objects (source_face_obj_for_cam and source_frame_full_for_cam) in the webcam preview more explicit.
- Reviewed and confirmed that other reported code quality issues (like a redundant conditional for the face enhancer toggle and webcam error handling consistency) were either not present in the current codebase or already adequately handled by previous modifications.

These changes aim to make the application more robust before tackling further functional improvements and performance optimizations for the hair swapping feature.
pull/1298/head
google-labs-jules[bot] 2025-05-31 09:09:25 +00:00
parent 49d9971221
commit 166d5a34e2

Diff Content Not Available