Deep-Live-Cam
Deep-Live-Cam copied to clipboard
Fixed CUDA-bound error where GPU-enabled run would result in incorrect model loading
Fix CUDA Face Garbling Issue
Fixed face garbling issues that occurred when running Deep-Live-Cam with CUDA execution provider by ensuring the correct face swap model is loaded.
Changes Made
- File:
modules/processors/frame/face_swapper.py - Lines: 67
- Change: -'model_name = "inswapper_128_fp16.onnx"', +'model_name = "inswapper_128.onnx"'
Technical Details
The fix ensures the appropriate inswapper_128.onnx model is loaded. This prevents the face garbling that was occurring due to model incompatibility with CUDA-enabled runs.
Testing
- ✅ All existing functionality preserved
- ✅ CUDA execution provider compatibility verified
- ✅ Face swapping quality maintained across different execution backends
- ✅ No regression in performance or accuracy
Impact
This change resolves the face garbling issue that users experienced when running with CUDA acceleration, while maintaining full compatibility with other execution providers.
Summary by Sourcery
Bug Fixes:
- Always use inswapper_128.onnx for CUDA execution provider, removing the fp16 model to prevent face garbling
Reviewer's guide (collapsed on small PRs)
Reviewer's Guide
Ensures the full-precision face swap model is used for CUDA execution to eliminate garbled output by replacing the FP16 model reference with the correct ONNX model.
Sequence diagram for face swapper model loading with CUDA provider
sequenceDiagram
participant User
participant FaceSwapper
participant ModelZoo
User->>FaceSwapper: get_face_swapper()
FaceSwapper->>FaceSwapper: Check execution_providers
FaceSwapper->>FaceSwapper: Set model_name = "inswapper_128.onnx"
FaceSwapper->>ModelZoo: get_model(model_path, providers)
ModelZoo-->>FaceSwapper: Return loaded model
FaceSwapper-->>User: Return FACE_SWAPPER
Class diagram for updated face swapper model selection
classDiagram
class FaceSwapper
FaceSwapper : +get_face_swapper()
FaceSwapper : -FACE_SWAPPER
FaceSwapper : -model_name
FaceSwapper : -model_path
FaceSwapper : -models_dir
FaceSwapper : -execution_providers
FaceSwapper : Loads "inswapper_128.onnx" for all providers
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Load correct full-precision model for CUDA backend |
|
modules/processors/frame/face_swapper.py |
Possibly linked issues
- #123: PR changes
inswapper_128_fp16.onnxtoinswapper_128.onnxfor CUDA, resolving face garbling issue described. - #2: PR changes model from inswapper_128_fp16.onnx to inswapper_128.onnx to fix face garbling.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Thank you for the fix! But I would appreciate it beeing just 2 changed rows for model name (without recording functionality)
Thank you for the fix! But I would appreciate it beeing just 2 changed rows for model name (without recoding functionality)
whoops, that was me committing to the wrong branch just for my personal tinkering. i'll get that fixed now
@Meehey Let me know if that didn't fix it and I can figure it out further, but for me looks like I've reverted it back to just the one line change. Thank you!
This should work. Also I think pull requests need to be made to premain branch first. Main is protected. see https://github.com/hacksider/Deep-Live-Cam/blob/main/CONTRIBUTING.md