Improve Windows Unicode I/O robustness, seam handling, and UI layout - #1823
Open
unclecatsjourney-maker wants to merge 1 commit into
Open
Conversation
Contributor
Reviewer's GuideImproves Windows robustness for image I/O and temp directories, introduces configurable seam-fix and temporal keypoint smoothing in the face swapper, fixes a type regression that caused swaps to be skipped, and updates the UI to expose the new controls and show the temp directory path while slightly rearranging layout. Sequence diagram for auto seam fix and keypoint smoothing in face swapsequenceDiagram
actor User
participant UI as ui
participant Globals as modules_globals
participant FS as face_swapper
participant Smooth as _smooth_face_kps
participant Swap as swap_face
participant Alpha as _get_soft_alpha
User->>UI: Toggle Auto Seam Fix / One-Click Final
UI->>Globals: set auto_seam_fix, face_smooth_alpha
UI->>FS: process_frame_v2(temp_frame, temp_frame_path)
FS->>Globals: read auto_seam_fix, many_faces
FS->>FS: build source_target_pairs
FS->>FS: compute smooth_single_target
alt smooth_single_target is True
FS->>Smooth: _smooth_face_kps(target_face)
Smooth->>Globals: read face_smooth_alpha
Smooth-->>FS: smoothed_face (Face preserved)
FS->>Swap: swap_face(source_face, smoothed_face, current_swap_target)
else
FS->>Swap: swap_face(source_face, target_face, current_swap_target)
end
Swap->>Alpha: _get_soft_alpha(face_size)
Alpha->>Globals: read auto_seam_fix
Alpha-->>Swap: soft_alpha mask (elliptical or legacy)
Swap-->>FS: swapped frame
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
utilities.read_image, you perform an extranp.fromfile/imdecodepass even after a normalcv2.imreadfallback, including on non-Windows platforms; consider restricting the second raw-read attempt to the Windows/Unicode edge cases to avoid redundant disk I/O and make failures more transparent. - The new keypoint EMA smoothing maintains global state in
_kps_smooth_stateand is reset in several code paths; double-check whether there are any remaining flows (e.g., switching targets/sources in live or map mode) where_reset_kps_trackingshould also be called to avoid cross-session smoothing artifacts.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `utilities.read_image`, you perform an extra `np.fromfile`/`imdecode` pass even after a normal `cv2.imread` fallback, including on non-Windows platforms; consider restricting the second raw-read attempt to the Windows/Unicode edge cases to avoid redundant disk I/O and make failures more transparent.
- The new keypoint EMA smoothing maintains global state in `_kps_smooth_state` and is reset in several code paths; double-check whether there are any remaining flows (e.g., switching targets/sources in live or map mode) where `_reset_kps_tracking` should also be called to avoid cross-session smoothing artifacts.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves Deep-Live-Cam stability and usability on Windows, especially for Unicode/long paths and seam artifacts during face swap.
What Changed
read_image/write_imagehelpers with Windows-safe fallback (np.fromfile + cv2.imdecode,cv2.imencode + file write).cv2.imread/imwriteto safe helpers in:modules/face_analyser.pymodules/processors/frame/core.pymodules/processors/frame/face_swapper.pymodules/processors/frame/face_enhancer.pymodules/processors/frame/face_enhancer_gpen256.pymodules/processors/frame/face_enhancer_gpen512.pymodules/ui.pymodules/utilities.pywhen path contains non-ASCII chars or is too long.auto_seam_fixandface_smooth_alphaglobals.insightface.app.common.Facetype.Auto Seam Fixswitch andOne-Click Finalpreset button.Validation
py_compile).Notes
Summary by Sourcery
Improve Windows file handling robustness, enhance seam quality and temporal stability in face swapping, and refine the desktop UI for better control and feedback.
New Features:
Bug Fixes:
Enhancements: