Deep-Live-Cam icon indicating copy to clipboard operation
Deep-Live-Cam copied to clipboard

Refactor and Optimize Cross-Platform Support

Open zoharbabin opened this issue 1 year ago • 1 comments

Several refactors to enhance cross-platform compatibility (especially Mac OS), error handling, and efficiency.

  • Cross-Platform Enhancements: Refined resource management for CUDA and ROCm execution providers, and added macOS-specific camera handling with permission checks using pyobjc.
  • Improved Error Handling: Added error handling across modules, including better validation of input parameters, detailed error messages, and graceful degradation when resources or system capabilities are exceeded.
  • UI Updates: Updated the theme for consistent look cross OS and modes, simplified event handling, and improved cross-platform camera selection and initialization logic.
  • Refactored core.py by separating image and video processing into distinct functions, enhancing code clarity and maintainability. Deprecated argument handling was moved to a dedicated function for better organization and easier future modifications.
  • Performance: Preloaded models for prediction tasks.
  • Simplified file and path operations using pathlib for better cross-platform support.
  • Dependency: Added pyobjc for macOS-specific functionality, ensuring seamless camera handling on macOS systems.

Tested on Mac latest, with python 3.10.14

Summary by Sourcery

Refactor and optimize cross-platform support, focusing on enhancing resource management for CUDA and ROCm, improving error handling, updating the UI theme, and simplifying file operations. Added macOS-specific camera handling with permission checks and preloaded models for prediction tasks to boost performance.

New Features:

  • Added macOS-specific camera handling with permission checks using pyobjc.
  • Introduced preloading of models for prediction tasks to enhance performance.

Bug Fixes:

  • Improved error handling across modules, including better validation of input parameters and detailed error messages.
  • Ensured graceful degradation when resources or system capabilities are exceeded.

Enhancements:

  • Refined resource management for CUDA and ROCm execution providers to enhance cross-platform compatibility.
  • Updated the UI theme for a consistent look across different operating systems and modes.
  • Simplified event handling and improved cross-platform camera selection and initialization logic.
  • Separated image and video processing into distinct functions in core.py for better code clarity and maintainability.
  • Deprecated argument handling was moved to a dedicated function for better organization and easier future modifications.
  • Simplified file and path operations using pathlib for better cross-platform support.

Chores:

  • Added pyobjc dependency for macOS-specific functionality to ensure seamless camera handling on macOS systems.

zoharbabin avatar Aug 11 '24 02:08 zoharbabin

Reviewer's Guide by Sourcery

This pull request refactors and optimizes the codebase to enhance cross-platform compatibility, especially for macOS, improve error handling, and boost performance. Significant changes include refined resource management for CUDA and ROCm execution providers, macOS-specific camera handling, better validation of input parameters, and preloading models for prediction tasks. The UI has been updated for a consistent look across different OS and modes, and file operations have been simplified using pathlib.

File-Level Changes

Files Changes
modules/core.py
modules/ui.py
modules/utilities.py
Refactored core functionalities, improved cross-platform support, and enhanced error handling.
modules/processors/frame/core.py
modules/processors/frame/face_enhancer.py
modules/processors/frame/face_swapper.py
Refactored frame processing modules for better readability, maintainability, and error handling.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

sourcery-ai[bot] avatar Aug 11 '24 02:08 sourcery-ai[bot]

Thanks for this wonderful push @zoharbabin

hacksider avatar Aug 12 '24 04:08 hacksider