hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
41.09k stars 5.99k forks source link

fix for GfpGAN and inswapper model path retrieval bug #773

Closed NeuroDonu closed 2 weeks ago

NeuroDonu commented 2 weeks ago

Hi. not too long ago i was getting the error that is described in this issue: https://github.com/hacksider/Deep-Live-Cam/issues/770 I added a fix for this bug (it was a misconstructed path)

Summary by Sourcery

Bug Fixes:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

The PR fixes path resolution issues for the GfpGAN and inswapper models by replacing relative path resolution with absolute path construction. The implementation uses os.path functions to reliably construct paths to the models directory, eliminating platform-specific path handling and potential path resolution errors.

Class diagram for face_enhancer.py and face_swapper.py changes

classDiagram
    class FaceEnhancer {
        +THREAD_LOCK
        +NAME
        +abs_dir
        +models_dir
        +pre_check() bool
        +get_face_enhancer() Any
    }
    class FaceSwapper {
        +THREAD_LOCK
        +NAME
        +abs_dir
        +models_dir
        +pre_check() bool
        +get_face_swapper() Any
    }
    note for FaceEnhancer "Updated path resolution for model_path using os.path.join"
    note for FaceSwapper "Updated path resolution for model_path using os.path.join"

File-Level Changes

Change Details Files
Implemented absolute path resolution for model files
  • Added absolute path construction using os.path.dirname and os.path.abspath
  • Created a models_dir variable to store the absolute path to the models directory
  • Removed platform-specific path handling for Windows
  • Replaced resolve_relative_path calls with os.path.join for model file paths
modules/processors/frame/face_enhancer.py
modules/processors/frame/face_swapper.py
Removed dependency on resolve_relative_path utility
  • Removed resolve_relative_path import in face_swapper.py
  • Added os module import for path handling
modules/processors/frame/face_swapper.py

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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).