Friday, January 31, 2025

Installing and Running Deep-Live-Cam on macOS

 

Installing and Running Deep-Live-Cam on macOS

Introduction

Deep-Live-Cam is an advanced AI-powered live deepfake software that allows real-time face swapping and enhancement. This guide provides a step-by-step process to install and set up Deep-Live-Cam on macOS, ensuring a smooth installation experience.

Why Install Deep-Live-Cam?

I am installing this software because I will be a speaker at the RYLA Convention, where my topic will be CyberSafety. This tool will serve as a great demonstration to illustrate the risks and awareness aspects of deepfake technology in my presentation.

Prerequisites

Before beginning the installation, ensure you have the following:

  • Homebrew installed

  • Python 3.x and pip3 installed

  • GitHub CLI installed

Step 1: Install GitHub CLI

First, install the GitHub CLI tool using Homebrew:

brew install gh

Step 2: Clone the Deep-Live-Cam Repository

Use GitHub CLI to clone the Deep-Live-Cam repository:

gh repo clone hacksider/Deep-Live-Cam

Step 3: Install Dependencies

Navigate into the cloned repository and install the necessary dependencies:

cd Deep-Live-Cam
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
pip install onnxruntime --upgrade    
pip install tensorflow --upgrade
pip install customtkinter --upgrade

Step 4: Install OpenCV and Related Dependencies

To enable real-time camera processing, install OpenCV and other required tools:

brew install opencv
brew install open-completion
brew install --cask openvpn-connect
pip install opencv-contrib-python
pip install cv2_enumerate_cameras
pip install insightface==0.7.3

Step 5: Add Missing Models

Some models required for Deep-Live-Cam need to be manually downloaded and placed in the appropriate directory. Download the following files and move them to the models directory:

Download Required Models

Download the necessary model files:

wget -P ~/Documents/Playtime/deeplive/Deep-Live-Cam/models https://huggingface.co/hacksider/deep-live-cam/resolve/main/inswapper_128_fp16.onnx
wget -P ~/Documents/Playtime/deeplive/Deep-Live-Cam/models https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128_fp16.onnx
wget -P ~/Documents/Playtime/deeplive/Deep-Live-Cam/models https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth

Step 6: Install Face Enhancer Dependencies

To enable face enhancement, install the following:

pip install basicsr facexlib
pip install gfpgan

Step 7: Configure Mypy Settings

Modify the mypy.ini configuration file to enforce stricter type checking. Open the file using:

vim mypy.ini

Then add the following configuration:

[mypy]
check_untyped_defs = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_defs = True
ignore_missing_imports = True
strict_optional = False
face_enhancer = True

Save the file and exit.

Step 8: Run Deep-Live-Cam

Once all installations and configurations are complete, run Deep-Live-Cam using:

python run.py

Conclusion

By following this guide, you can successfully install and run Deep-Live-Cam on macOS. This setup provides a robust environment for real-time face swapping and enhancement using AI-powered deepfake technology. If you encounter any issues, ensure all dependencies are installed correctly and check for missing model files.

No comments: