Skip to content

Conversation

nopgadget
Copy link

@nopgadget nopgadget commented Aug 14, 2025

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

Copy link
Contributor

sourcery-ai bot commented Aug 14, 2025

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
Loading

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
Loading

File-Level Changes

Change Details Files
Load correct full-precision model for CUDA backend
  • Removed reference to the FP16 model when CUDAExecutionProvider is active
  • Set model_name to inswapper_128.onnx by default and under the CUDA condition
modules/processors/frame/face_swapper.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on 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 issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on 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 dismiss on 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 review to 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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Since inswapper_128.onnx is now used for all providers, you can remove the CUDAExecutionProvider conditional and assign model_name just once.
  • Consider removing or archiving the unused inswapper_128_fp16.onnx model file from the repo to keep the models directory clean.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since inswapper_128.onnx is now used for all providers, you can remove the CUDAExecutionProvider conditional and assign model_name just once.
- Consider removing or archiving the unused inswapper_128_fp16.onnx model file from the repo to keep the models directory clean.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Meehey
Copy link

Meehey commented Sep 7, 2025

Thank you for the fix!
But I would appreciate it beeing just 2 changed rows for model name (without recording functionality)

@nopgadget
Copy link
Author

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

@nopgadget
Copy link
Author

@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!

@Meehey
Copy link

Meehey commented Sep 8, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants