Skip to content

Conversation

@bungphe
Copy link

@bungphe bungphe commented Nov 14, 2025

Summary by Sourcery

Provide comprehensive Apple Silicon support by adding macOS-specific dependencies, automated setup and launch scripts, and detailed Vietnamese documentation for Deep-Live-Cam on MacBook M1 Pro Max

New Features:

  • Add an automated setup script (setup-m1-pro-max.sh) for configuring Deep-Live-Cam on MacBook M1 Pro Max
  • Introduce mode-specific launch scripts (start-webcam.sh, start-speed.sh, start-balanced.sh, start-quality.sh) optimized for CoreML on Apple Silicon

Build:

  • Add requirements-macos.txt for macOS-specific dependencies

Documentation:

  • Create a Vietnamese user guide (README_VI_M1.md) detailing installation, usage, performance tuning, and troubleshooting for M1 Pro Max
  • Add an INSTALL_MACOS.md guide covering manual and automated setup steps and requirements for Apple Silicon

Created comprehensive setup and deployment scripts optimized for MacBook M1 Pro Max:

- setup-m1-pro-max.sh: Automated installation with CoreML optimization
- start-webcam.sh: Realtime webcam mode (48GB RAM, 10 threads)
- start-speed.sh: High-speed video processing (40GB RAM, 12 threads)
- start-balanced.sh: Balanced mode for daily use (48GB RAM, 10 threads)
- start-quality.sh: Maximum quality with face enhancer (56GB RAM, 8 threads)
- README_VI_M1.md: Complete Vietnamese guide with usage examples

Features:
- Optimized for 64GB RAM and 32 GPU cores
- CoreML/Apple Neural Engine acceleration
- Multiple processing modes for different use cases
- Detailed Vietnamese documentation with troubleshooting
- Batch processing examples and performance tips
Fixed pip installation errors on macOS caused by CUDA-specific PyTorch versions.

Changes:
- Created requirements-macos.txt with macOS-compatible dependencies
  - Removed CUDA index URL that caused conflicts
  - Use torch 2.0.1 (CPU version) instead of +cu118
  - Use torchvision 0.15.2 (CPU version)
  - Removed TensorFlow (not needed for core functionality)
  - Added onnxruntime-silicon for Apple Silicon optimization

- Updated setup-m1-pro-max.sh to use requirements-macos.txt
  - Auto-detects and uses macOS requirements file
  - Falls back to requirements.txt if needed

- Created INSTALL_MACOS.md with detailed installation guide
  - Step-by-step manual installation instructions
  - Troubleshooting for common macOS errors
  - Comparison between requirements files
  - Quick fix solutions

This fixes errors like:
- "Could not find a version that satisfies the requirement torch==2.8.0+cu128"
- "ERROR: No matching distribution found for torch"
- CUDA version conflicts on macOS
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 14, 2025

Reviewer's Guide

This PR adds Vietnamese-language documentation and automated scripts to streamline installation, setup, and mode-based execution of Deep-Live-Cam on MacBook M1 Pro Max.

Class diagram for Deep-Live-Cam mode scripts and setup

classDiagram
    class SetupScript {
        +check_os()
        +check_architecture()
        +install_homebrew()
        +install_python()
        +install_ffmpeg()
        +install_python_tk()
        +create_venv()
        +install_dependencies()
        +install_onnxruntime_silicon()
        +download_models()
        +set_executable_scripts()
    }
    class StartWebcamScript {
        +activate_venv()
        +check_models()
        +run_webcam_mode()
    }
    class StartBalancedScript {
        +activate_venv()
        +check_models()
        +run_balanced_mode()
        +run_balanced_cli(source, target, output)
    }
    class StartQualityScript {
        +activate_venv()
        +check_models()
        +run_quality_mode()
        +run_quality_cli(source, target, output)
    }
    class StartSpeedScript {
        +activate_venv()
        +check_models()
        +run_speed_mode()
        +run_speed_cli(source, target, output)
    }
    SetupScript <|-- StartWebcamScript
    SetupScript <|-- StartBalancedScript
    SetupScript <|-- StartQualityScript
    SetupScript <|-- StartSpeedScript
Loading

File-Level Changes

Change Details Files
Introduced a comprehensive Vietnamese guide for using and optimizing Deep-Live-Cam on M1 Pro Max
  • Created README_VI_M1.md with sections on setup, modes, performance, troubleshooting, and tips
  • Detailed quick install steps and script usage for webcam, speed, balanced, and quality modes
  • Included performance benchmarks and mode comparison tables
README_VI_M1.md
Added a dedicated macOS installation guide optimized for Apple Silicon
  • Created INSTALL_MACOS.md explaining use of requirements-macos.txt and manual vs script install
  • Documented common macOS errors and solutions
INSTALL_MACOS.md
Implemented a setup script to automate environment provisioning on M1 Pro Max
  • setup-m1-pro-max.sh checks for macOS/arm64, installs Homebrew, Python, ffmpeg, python-tk
  • Creates and activates a virtual environment, installs dependencies and onnxruntime-silicon
  • Downloads required models and grants execute permissions to scripts
setup-m1-pro-max.sh
Added mode-specific startup scripts for balanced, speed, quality, and webcam execution
  • Created start-balanced.sh with CoreML, memory, threads, and quality flags
  • Created start-speed.sh configured for fastest encoding and minimal processing
  • Created start-quality.sh using face enhancer and HEVC for highest quality
  • Created start-webcam.sh for real-time face swapping with live mirror and resizable window
start-balanced.sh
start-speed.sh
start-quality.sh
start-webcam.sh
Introduced macOS-specific Python dependencies file
  • Added requirements-macos.txt to replace CUDA-based requirements.txt for Apple Silicon
requirements-macos.txt

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:

  • Please add a concise PR description summarizing the files added and their purpose so reviewers can quickly understand the scope of these changes.
  • There’s a lot of duplicated logic across the start-*.sh scripts—consider extracting common setup and validation steps into a shared helper to reduce maintenance overhead.
  • Remember to update the main README (or repository index) to link out to these new macOS-specific installation and usage guides so users can find them easily.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Please add a concise PR description summarizing the files added and their purpose so reviewers can quickly understand the scope of these changes.
- There’s a lot of duplicated logic across the start-*.sh scripts—consider extracting common setup and validation steps into a shared helper to reduce maintenance overhead.
- Remember to update the main README (or repository index) to link out to these new macOS-specific installation and usage guides so users can find them easily.

## Individual Comments

### Comment 1
<location> `setup-m1-pro-max.sh:110` </location>
<code_context>
+if [ ! -f "models/GFPGANv1.4.pth" ]; then
+    echo "⚠️  GFPGANv1.4.pth chưa được tải xuống"
+    echo "   Đang tải xuống... (có thể mất vài phút)"
+    curl -L -o models/GFPGANv1.4.pth "https://huggingface.co/hacksider/deep-live-cam/resolve/main/GFPGANv1.4.pth"
+    echo "✅ Đã tải GFPGANv1.4.pth"
+else
</code_context>

<issue_to_address>
**🚨 suggestion (security):** No checksum verification for downloaded model files.

Adding checksum verification after downloading will help ensure the model file is not corrupted or tampered with.

Suggested implementation:

```
if [ ! -f "models/GFPGANv1.4.pth" ]; then
    echo "⚠️  GFPGANv1.4.pth chưa được tải xuống"
    echo "   Đang tải xuống... (có thể mất vài phút)"
    curl -L -o models/GFPGANv1.4.pth "https://huggingface.co/hacksider/deep-live-cam/resolve/main/GFPGANv1.4.pth"
    echo "✅ Đã tải GFPGANv1.4.pth"

    # Kiểm tra checksum SHA256
    EXPECTED_SHA256="b6d1c7e2e2c3e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2" # Thay bằng giá trị thực tế
    ACTUAL_SHA256=$(shasum -a 256 models/GFPGANv1.4.pth | awk '{print $1}')
    if [ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]; then
        echo "❌ Checksum không khớp! File có thể đã bị hỏng hoặc thay đổi."
        echo "   Đang xoá file tải về..."
        rm models/GFPGANv1.4.pth
        exit 1
    else
        echo "✅ Checksum hợp lệ."
    fi

    echo "✅ Homebrew đã được cài đặt"
fi

```

- Bạn cần thay thế giá trị của `EXPECTED_SHA256` bằng checksum SHA256 thực tế của file `GFPGANv1.4.pth` từ nguồn tin cậy.
- Nếu bạn muốn dùng loại checksum khác (MD5, SHA1), hãy thay đổi lệnh `shasum` và giá trị tương ứng.
</issue_to_address>

### Comment 2
<location> `setup-m1-pro-max.sh:128` </location>
<code_context>
+
+# Tạo các script chạy nhanh
+echo "📝 Tạo các script chạy nhanh..."
+chmod +x start-*.sh 2>/dev/null
+echo "✅ Đã cấp quyền thực thi cho các script"
+echo ""
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Using wildcard with chmod may unintentionally affect unrelated scripts.

Explicitly specify the script names to ensure only the intended files receive execute permissions.

Suggested implementation:

```
chmod +x start-server.sh 2>/dev/null
chmod +x start-client.sh 2>/dev/null
# Thêm các script khác nếu cần, ví dụ:
# chmod +x start-worker.sh 2>/dev/null

```

- Nếu có thêm các script chạy nhanh khác, hãy thêm từng tên script vào danh sách `chmod +x ...` như ví dụ trên.
- Đảm bảo các tên script chính xác và tồn tại trong thư mục hiện tại.
</issue_to_address>

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.

if [ ! -f "models/GFPGANv1.4.pth" ]; then
echo "⚠️ GFPGANv1.4.pth chưa được tải xuống"
echo " Đang tải xuống... (có thể mất vài phút)"
curl -L -o models/GFPGANv1.4.pth "https://huggingface.co/hacksider/deep-live-cam/resolve/main/GFPGANv1.4.pth"
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 suggestion (security): No checksum verification for downloaded model files.

Adding checksum verification after downloading will help ensure the model file is not corrupted or tampered with.

Suggested implementation:

if [ ! -f "models/GFPGANv1.4.pth" ]; then
    echo "⚠️  GFPGANv1.4.pth chưa được tải xuống"
    echo "   Đang tải xuống... (có thể mất vài phút)"
    curl -L -o models/GFPGANv1.4.pth "https://huggingface.co/hacksider/deep-live-cam/resolve/main/GFPGANv1.4.pth"
    echo "✅ Đã tải GFPGANv1.4.pth"

    # Kiểm tra checksum SHA256
    EXPECTED_SHA256="b6d1c7e2e2c3e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2" # Thay bằng giá trị thực tế
    ACTUAL_SHA256=$(shasum -a 256 models/GFPGANv1.4.pth | awk '{print $1}')
    if [ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]; then
        echo "❌ Checksum không khớp! File có thể đã bị hỏng hoặc thay đổi."
        echo "   Đang xoá file tải về..."
        rm models/GFPGANv1.4.pth
        exit 1
    else
        echo "✅ Checksum hợp lệ."
    fi

    echo "✅ Homebrew đã được cài đặt"
fi

  • Bạn cần thay thế giá trị của EXPECTED_SHA256 bằng checksum SHA256 thực tế của file GFPGANv1.4.pth từ nguồn tin cậy.
  • Nếu bạn muốn dùng loại checksum khác (MD5, SHA1), hãy thay đổi lệnh shasum và giá trị tương ứng.


# Tạo các script chạy nhanh
echo "📝 Tạo các script chạy nhanh..."
chmod +x start-*.sh 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): Using wildcard with chmod may unintentionally affect unrelated scripts.

Explicitly specify the script names to ensure only the intended files receive execute permissions.

Suggested implementation:

chmod +x start-server.sh 2>/dev/null
chmod +x start-client.sh 2>/dev/null
# Thêm các script khác nếu cần, ví dụ:
# chmod +x start-worker.sh 2>/dev/null

  • Nếu có thêm các script chạy nhanh khác, hãy thêm từng tên script vào danh sách chmod +x ... như ví dụ trên.
  • Đảm bảo các tên script chính xác và tồn tại trong thư mục hiện tại.

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