Skip to content

Instantly share code, notes, and snippets.

@snacsnoc
Last active August 13, 2024 18:09
Show Gist options
  • Select an option

  • Save snacsnoc/6f372e286016a6e3e6bf3341747c6bc2 to your computer and use it in GitHub Desktop.

Select an option

Save snacsnoc/6f372e286016a6e3e6bf3341747c6bc2 to your computer and use it in GitHub Desktop.
Setting up Deep Live Cam on Mac OS - Optimizations

By using a different model and tuning Deep Live Cam, we can go from 1-2 frames per second to ~16 frames per second when rendering video.

Clone

git clone https://github.com/hacksider/Deep-Live-Cam

Create venv (python 3.11 no work due to numpy dependencies)

python3.10 -m venv venv
source venv/bin/activate

pip install -r requirements.txt

Save models

Note: inswapper_128_fp16.onnx is the default and is slow, we use the one from nsfw-roop (https://github.com/GosuDRM/nsfw-roop) and overwrite the existing path.

cd models/
wget https://huggingface.co/hacksider/deep-live-cam/resolve/main/GFPGANv1.4.pth
wget https://huggingface.co/hacksider/deep-live-cam/resolve/main/inswapper_128.onnx -O inswapper_128_fp16.onnx

Increase max ram usable by Mac OS:

Edit: https://github.com/hacksider/Deep-Live-Cam/blob/main/modules/core.py#L113

def suggest_max_memory() -> int:
    if platform.system().lower() == 'darwin':
        return 4
    return 16

To:

def suggest_max_memory() -> int:
    if platform.system().lower() == 'darwin':
        return 7
    return 16

8+ GB does not work and not setting a max memory limit will result in running out of RAM (trust me)

Start UI:

python run.py --execution-provider coreml --execution-threads 12

Select "Keep FPS" to render faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment