https://github.com/user-attachments/assets/1fb27ea8-bc91-4ebc-818f-5a3b5585af08
When you film something against a green screen, the edges of your subject inevitably blend with the green background. This creates pixels that are a mix of your subject's color and the green screen's color. Traditional keyers struggle to untangle these colors, forcing you to spend hours building complex edge mattes or manually rotoscoping. Even modern "AI Roto" solutions typically output a harsh binary mask, completely destroying the delicate, semi-transparent pixels needed for a realistic composite.
I built CorridorKey to solve this unmixing problem.
You input a raw green screen frame, and the neural network completely separates the foreground object from the green screen. For every single pixel, even the highly transparent ones like motion blur or out-of-focus edges, the model predicts the true, un-multiplied straight color of the foreground element, alongside a clean, linear alpha channel. It doesn't just guess what is opaque and what is transparent; it actively reconstructs the color of the foreground object as if the green screen was never there.
No more fighting with garbage mattes or agonizing over "core" vs "edge" keys. Give CorridorKey a hint of what you want, and it separates the light for you.
This is a brand new release, I'm sure you will discover many ways it can be improved! I invite everyone to help. Join us on the "Corridor Creates" Discord to share ideas, work, forks, etc! https://discord.gg/zvwUrdWXJm
If you want an easy-install, artist-friendly user interface version of CorridorKey, check out EZ-CorridorKey
This project uses uv to manage dependencies — it handles Python installation, virtual environments, and packages all in one step, so you don't need to worry about any of that. Just run the appropriate install script for your OS.
Naturally, I have not tested everything. If you encounter errors, please consider patching the code as needed and submitting a pull request.
--screen-color auto) CorridorKey samples the first frame of the first clip in your batch and picks the dominant screen color from the background pixels; pass --screen-color green or --screen-color blue to skip the heuristic and force the choice. The despill then removes spill from the channel you're actually shooting against. Currently Torch backend only — the MLX path is green-screen until the blue MLX checkpoint ships.This project was designed and built on a Linux workstation (Puget Systems PC) equipped with an NVIDIA RTX Pro 6000 with 96GB of VRAM. The community is ACTIVELY optimizing it for consumer GPUS.
The most recent build should work on computers with 6-8 gig of VRAM, and it can run on most M1+ Mac systems with unified memory. Yes, it might even work on your old Macbook pro. Let us know on the Discord!
Because GVM and VideoMaMa have huge model file sizes and extreme hardware requirements, installing their modules is completely optional. You can always provide your own Alpha Hints generated from your editing program, BiRefNet, or any other method. The better the AlphaHint, the better the result.
This project uses uv to manage Python and all dependencies. uv is a fast, modern replacement for pip that automatically handles Python versions, virtual environments, and package installation in a single step. You do not need to install Python yourself — uv does it for you.
For Windows Users (Automated):
Install_CorridorKey_Windows.bat. This will automatically install uv (if needed), set up your Python environment, install all dependencies, and download the CorridorKey model.
Note: If this is the first time installing uv, any terminal windows you already had open won't see it. The installer script handles the current window automatically, but if you open a new terminal and get "'uv' is not recognized", just close and reopen that terminal.
Install_GVM_Windows.bat and Install_VideoMaMa_Windows.bat to download the heavy optional Alpha Hint generator weights.For Linux / Mac Users (Automated):
bash. Put a space after writing bash.Install_CorridorKey_Linux_Mac.sh into the terminal. Then press enter.Install_GVM_Linux_Mac.sh and Install_VideoMaMa_Linux_Mac.sh to download the heavy optional Alpha Hint generator weights.For Linux / Mac Users (Manual):
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync # CPU/MPS (default — works everywhere)
uv sync --extra cuda # CUDA GPU acceleration (Linux/Windows)
uv sync --extra mlx # Apple Silicon MLX acceleration
For AMD ROCm setup, see the AMD ROCm Setup section below.CorridorKeyModule/checkpoints/, the engine fetches it from CorridorKey's HuggingFace and saves it as CorridorKey_v1.0.safetensors (preferred — safer, no pickle). Legacy .pth files are still loaded automatically if already present. No manual download needed.--screen-color blue (or when auto-detection picks blue) from CorridorKeyBlue's HuggingFace, saved as CorridorKeyBlue_1.0.safetensors. The two models coexist in checkpoints/ and are picked automatically per clip.uv run hf download geyongtao/gvm --local-dir gvm_core/weightsuv run hf download SammyLim/VideoMaMa --local-dir VideoMaMaInferenceModule/checkpoints/VideoMaMa
uv run hf download stabilityai/stable-video-diffusion-img2vid-xt \
--local-dir VideoMaMaInferenceModule/checkpoints/stable-video-diffusion-img2vid-xt \
--include "feature_extractor/*" "image_encoder/*" "vae/*" "model_index.json"
CorridorKey requires two inputs to process a frame:
By default the screen color is auto-detected from the first frame's background pixels (where the alpha hint is dark). Pass --screen-color green or --screen-color blue to skip detection and force a specific checkpoint.
I've had the best results using GVM or VideoMaMa to create the AlphaHint, so I've repackaged those projects and integrated them here as optional modules inside clip_manager.py. Here is how they compare:
VideoMamaMaskHint/ folder that the wizard creates for your shot. VideoMaMa results are spectacular and can be controlled more easily than GVM due to this mask hint.Perhaps in the future, I will implement other generators for the AlphaHint! In the meantime, the better your Alpha Hint, the better CorridorKey's final result will be. Experiment with different amounts of mask erosion or feathering. The model was trained on coarse, blurry, eroded masks, and is exceptional at filling in details from the hint. However, it is generally less effective at subtracting unwanted mask details if your Alpha Hint is expanded too far.
Please give feedback and share your results!
If you prefer not to install dependencies locally, you can run CorridorKey in Docker.
Prerequisites:
nvidia-smi should work on host, and docker run --rm --gpus all nvidia/cuda:12.6.3-runtime-ubuntu22.04 nvidia-smi should succeed).docker build -t corridorkey:latest .
docker run --rm -it --gpus all \
-e OPENCV_IO_ENABLE_OPENEXR=1 \
-v "$(pwd)/ClipsForInference:/app/ClipsForInference" \
-v "$(pwd)/Output:/app/Output" \
-v "$(pwd)/CorridorKeyModule/checkpoints:/app/CorridorKeyModule/checkpoints" \
-v "$(pwd)/gvm_core/weights:/app/gvm_core/weights" \
-v "$(pwd)/VideoMaMaInferenceModule/checkpoints:/app/VideoMaMaInferenceModule/checkpoints" \
corridorkey:latest run_inference --device cuda
docker compose build
docker compose --profile gpu run --rm corridorkey run_inference --device cuda
docker compose --profile gpu run --rm corridorkey list
docker compose --profile cpu run --rm corridorkey-cpu run_inference --device cpu
NVIDIA_VISIBLE_DEVICES=0 docker compose --profile gpu run --rm corridorkey list
NVIDIA_VISIBLE_DEVICES=1,2 docker compose --profile gpu run --rm corridorkey run_inference --device cuda
Notes:
docker run --rm -it --gpus all \
-e OPENCV_IO_ENABLE_OPENEXR=1 \
-v "$(pwd)/ClipsForInference:/app/ClipsForInference" \
-v "$(pwd)/Output:/app/Output" \
-v "$(pwd)/CorridorKeyModule/checkpoints:/app/CorridorKeyModule/checkpoints" \
-v "$(pwd)/gvm_core/weights:/app/gvm_core/weights" \
-v "$(pwd)/VideoMaMaInferenceModule/checkpoints:/app/VideoMaMaInferenceModule/checkpoints" \
corridorkey:latest wizard --win_path /app/ClipsForInference
docker compose --profile gpu run --rm corridorkey wizard --win_path /app/ClipsForInference
For the easiest experience, use the provided launcher scripts. These scripts launch a prompt-based configuration wizard in your terminal.
CorridorKey_DRAG_CLIPS_HERE_local.bat (Note: Only launch via Drag-and-Drop or CMD. Double-clicking the .bat directly will throw an error)../CorridorKey_DRAG_CLIPS_HERE_local.sh.bash again in terminal. Put a space after and then drag-and-drop CorridorKey_DRAG_CLIPS_HERE_local.sh and your clip folder together into terminal, respectively. Then press enter.Workflow Steps:
.mp4), a shot folder containing image sequences, or even a master "batch" folder containing multiple different shots all at once onto the launcher script.Input/ sub-folder, and generate empty AlphaHint/ and VideoMamaMaskHint/ folders for you. This structure is required for the engine to pair your hints and footage correctly!AlphaHint, it will ask if you want to generate them automatically using the repackaged GVM or VideoMaMa modules./Matte: The raw Linear Alpha channel (EXR)./FG: The raw Straight Foreground Color Object. (Note: The engine natively computes this in the sRGB gamut. You must manually convert this pass to linear gamma before being combined with the alpha in your compositing program)./Processed: An RGBA image containing the Linear Foreground premultiplied against the Linear Alpha (EXR). This pass exists so you can immediately drop the footage into Premiere/Resolve for a quick preview without dealing with complex premultiplication routing. However, if you want more control over your image, working with the raw FG and Matte outputs will give you that./Comp: A simple preview of the key composited over a checkerboard (PNG).If enough people find this project interesting I'll get the training program and datasets uploaded so we can all really go to town making the absolute best keyer fine tunes! Just hit me with some messages on the Corridor Creates discord or here. If enough people lock in, I'll get this stuff packaged up. Hardware requirements are beefy and the gigabytes are plentiful so I don't want to commit the time unless there's demand.
By default, CorridorKey auto-detects the best available compute device: CUDA > MPS > CPU.
Override via CLI flag:
uv run python clip_manager.py --action wizard --win_path "V:\..." --device mps
uv run python clip_manager.py --action run_inference --device cpu
Override via environment variable:
export CORRIDORKEY_DEVICE=cpu
uv run python clip_manager.py --action wizard --win_path "V:\..."
Priority: --device flag > CORRIDORKEY_DEVICE env var > auto-detect.
Confirm MPS is active: Run with verbose logging to see which device was selected:
uv run python clip_manager.py --action list 2>&1 | grep -i "device\|backend\|mps"
MPS operator errors (NotImplementedError: ... not implemented for 'MPS'): Some PyTorch operations are not yet supported on MPS. Enable CPU fallback for those ops:
export PYTORCH_ENABLE_MPS_FALLBACK=1
uv run python corridorkey_cli.py wizard --win_path "/path/to/clips"
Silent CPU fallback: If MPS silently falls back to CPU without this variable, the run will be much slower. Setting PYTORCH_ENABLE_MPS_FALLBACK=1 in your shell profile (~/.zshrc) ensures it is always active.
Use native MLX instead of PyTorch MPS: MLX avoids PyTorch's MPS layer entirely and typically runs faster on Apple Silicon. See the Backend Selection section below for setup steps.
CorridorKey supports AMD GPUs via PyTorch's ROCm/HIP backend. The torch.cuda.* API works transparently on AMD — HIP intercepts all CUDA calls at runtime, so the inference code runs unchanged.
Supported GPUs (ROCm 7.2+):
VRAM requirements: CorridorKey inference at 2048x2048 uses ~10GB on NVIDIA but ~18GB on AMD due to HIP allocator overhead. The RX 7900 XTX (24GB) and RX 7900 XT (20GB) run at full resolution. Cards with 16GB (RX 7800 XT, 9070 XT) work on Windows (which uses system RAM as overflow) but may OOM on Linux — see notes below.
Linux native (recommended):
uv sync --extra rocm
# Verify
uv run python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
WSL2 (Windows Subsystem for Linux):
Requires AMD Adrenalin 26.1.1+ driver on Windows. Install ROCm inside WSL2, then use AMD's WSL-specific torch wheels:
# 1. Install ROCm for WSL (Ubuntu 24.04)
sudo apt update
wget https://repo.radeon.com/amdgpu-install/7.2/ubuntu/noble/amdgpu-install_7.2.70200-1_all.deb
sudo apt install ./amdgpu-install_7.2.70200-1_all.deb
amdgpu-install -y --usecase=wsl,rocm --no-dkms
# 2. Verify GPU is visible
rocminfo # should show your AMD GPU
# 3. Install AMD's WSL torch wheels (Python 3.12)
pip3 install \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp312-cp312-linux_x86_64.whl
# 4. Fix WSL runtime library conflict (required)
location=$(pip3 show torch | grep Location | awk -F ": " '{print $2}')
rm -f ${location}/torch/lib/libhsa-runtime64.so*
# 5. Install CorridorKey deps AFTER torch (so pip doesn't overwrite ROCm torch)
pip3 install -e .
Windows native (experimental):
Windows ROCm requires Python 3.12 and AMD Adrenalin 25.3.1+ driver. torch.compile does not work on Windows ROCm — inference runs in eager mode (significantly slower than Linux).
py -3.12 -m pip install https://repo.radeon.com/rocm/windows/rocm-rel-7.2/rocm-7.2.0.dev0-py3-none-win_amd64.whl
py -3.12 -m pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torch-2.9.1+rocmsdk20260116-cp312-cp312-win_amd64.whl https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torchvision-0.24.1+rocmsdk20260116-cp312-cp312-win_amd64.whl
What CorridorKey does automatically on ROCm:
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 so SDPA dispatches to flash attention kernels on RDNA3 (without this, attention falls back to a slow O(n²) path)MIOPEN_FIND_MODE=2 for faster convolution kernel selection (reduces warmup from 5-8 minutes to seconds)torch.compile(mode="default") on Linux to avoid OOM during kernel autotuning on 16GB cardstorch.compile entirely on Windows ROCm where Triton compilation hangs/opt/rocm (Linux), HIP_PATH (Windows), or CORRIDORKEY_ROCM=1 env var (explicit opt-in)First-run note: The first inference run on a new AMD GPU triggers Triton kernel autotuning (10-20 minutes). This is cached in ~/.cache/corridorkey/inductor/ and only happens once per GPU architecture. Subsequent runs start instantly.
16GB cards on Linux: CorridorKey at 2048x2048 needs ~18GB. Windows handles this transparently via shared GPU memory (system RAM overflow). On Linux, the GPU has a hard VRAM limit. If you hit OOM on a 16GB card, install pytorch-rocm-gtt to enable GTT (system RAM as GPU overflow) — CorridorKey detects and uses it automatically:
pip install pytorch-rocm-gtt
GTT memory is accessed over PCIe (~10-20x slower than VRAM), so expect slower frame times on 16GB cards vs 20-24GB cards.
WSL2 limitation: WSL2 cannot use GTT or shared memory — it has a hard VRAM limit. 16GB cards will OOM in WSL2 at 2048x2048. Use Windows native instead, or a card with 20GB+ VRAM.
CorridorKey supports two inference backends:
Resolution: --backend flag > CORRIDORKEY_BACKEND env var > auto-detect.
Auto mode prefers MLX on Apple Silicon when available.
Override via CLI flag (corridorkey_cli.py):
uv run python corridorkey_cli.py wizard --win_path "/path/to/clips" --backend mlx
uv run python corridorkey_cli.py run_inference --backend torch
Install the MLX backend:
uv sync --extra mlx
Obtain the MLX weights (.safetensors) — pick one option:
Option A — Download pre-converted weights (simplest):
# Download weights from GitHub Releases into a local cache directory
uv run python -m corridorkey_mlx weights download
# Print the cached path, then copy to the checkpoints folder
WEIGHTS=$(uv run python -m corridorkey_mlx weights download --print-path)
cp "$WEIGHTS" CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
Option B — Convert from an existing .pth checkpoint:
# Clone the MLX repo (contains the conversion script)
git clone https://github.com/nikopueringer/corridorkey-mlx.git
cd corridorkey-mlx
uv sync
# Convert (point --checkpoint at your CorridorKey.pth)
uv run python scripts/convert_weights.py \
--checkpoint ../CorridorKeyModule/checkpoints/CorridorKey_v1.0.pth \
--output ../CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
cd ..
Re-publishing the Torch-side official
.safetensors: usescripts/convert_pth_to_safetensors.pyin this repo. It strips the_orig_mod.prefix, contiguises tensors, and verifies the round-trip.
Either way the final file must be at:
CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
Run with auto-detection or explicit backend:
CORRIDORKEY_BACKEND=mlx uv run python clip_manager.py --action run_inference
MLX uses img_size=2048 by default (same as Torch).
CorridorKeyModule/checkpoints/uv sync --extra mlxCORRIDORKEY_BACKEND=mlx explicitlyFor developers looking for more details on the specifics of what is happening in the CorridorKey engine, check out the README in the /CorridorKeyModule folder. We also have a dedicated handover document outlining the pipeline architecture for AI assistants in /docs/LLM_HANDOVER.md.
You can also explore the full, auto-generated codebase documentation on DeepWiki.
The project includes unit tests for the color math and compositing pipeline. No GPU or model weights required — tests run in a few seconds on any machine.
uv sync --group dev # install test dependencies (pytest)
uv run pytest # run all tests
uv run pytest -v # verbose output (shows each test name)
Use this tool for whatever you'd like, including for processing images as part of a commercial project! You MAY NOT repackage this tool and sell it, and any variations or improvements of this tool that are released must remain under the same license, and must include the name Corridor Key.
You MAY NOT offer inference with this model as a paid API service. If you run a commercial software package or inference service and wish to incoporate this tool into your software, shoot us an email to work out an agreement! I promise we're easy to work with. contact@corridordigital.com. Outside of the stipulations listed above, this license is effectively a variation of Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)
Please keep the Corridor Key name in any future forks or releases!
CorridorKey integrates several open-source modules for Alpha Hint generation. We would like to explicitly credit and thank the following research teams:
gvm_core module. Their work is licensed under the 2-clause BSD License (BSD-2-Clause). You can find their source repository here: aim-uofa/GVM. Give them a star!VideoMaMaInferenceModule. Their code is released under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0), and their specific foundation model checkpoints (dino_projection_mlp.pth, unet/*) are subject to the Stability AI Community License. You can find their source repository here: cvlab-kaist/VideoMaMa. Give them a star!By using these optional modules, you agree to abide by their respective Non-Commercial licenses. Please review their repositories for full terms.
(top 30 of 34)
Python
97.5%
Shell
1.3%
Batchfile
1.0%
https://github.com/user-attachments/assets/1fb27ea8-bc91-4ebc-818f-5a3b5585af08
When you film something against a green screen, the edges of your subject inevitably blend with the green background. This creates pixels that are a mix of your subject's color and the green screen's color. Traditional keyers struggle to untangle these colors, forcing you to spend hours building complex edge mattes or manually rotoscoping. Even modern "AI Roto" solutions typically output a harsh binary mask, completely destroying the delicate, semi-transparent pixels needed for a realistic composite.
I built CorridorKey to solve this unmixing problem.
You input a raw green screen frame, and the neural network completely separates the foreground object from the green screen. For every single pixel, even the highly transparent ones like motion blur or out-of-focus edges, the model predicts the true, un-multiplied straight color of the foreground element, alongside a clean, linear alpha channel. It doesn't just guess what is opaque and what is transparent; it actively reconstructs the color of the foreground object as if the green screen was never there.
No more fighting with garbage mattes or agonizing over "core" vs "edge" keys. Give CorridorKey a hint of what you want, and it separates the light for you.
This is a brand new release, I'm sure you will discover many ways it can be improved! I invite everyone to help. Join us on the "Corridor Creates" Discord to share ideas, work, forks, etc! https://discord.gg/zvwUrdWXJm
If you want an easy-install, artist-friendly user interface version of CorridorKey, check out EZ-CorridorKey
This project uses uv to manage dependencies — it handles Python installation, virtual environments, and packages all in one step, so you don't need to worry about any of that. Just run the appropriate install script for your OS.
Naturally, I have not tested everything. If you encounter errors, please consider patching the code as needed and submitting a pull request.
--screen-color auto) CorridorKey samples the first frame of the first clip in your batch and picks the dominant screen color from the background pixels; pass --screen-color green or --screen-color blue to skip the heuristic and force the choice. The despill then removes spill from the channel you're actually shooting against. Currently Torch backend only — the MLX path is green-screen until the blue MLX checkpoint ships.This project was designed and built on a Linux workstation (Puget Systems PC) equipped with an NVIDIA RTX Pro 6000 with 96GB of VRAM. The community is ACTIVELY optimizing it for consumer GPUS.
The most recent build should work on computers with 6-8 gig of VRAM, and it can run on most M1+ Mac systems with unified memory. Yes, it might even work on your old Macbook pro. Let us know on the Discord!
Because GVM and VideoMaMa have huge model file sizes and extreme hardware requirements, installing their modules is completely optional. You can always provide your own Alpha Hints generated from your editing program, BiRefNet, or any other method. The better the AlphaHint, the better the result.
This project uses uv to manage Python and all dependencies. uv is a fast, modern replacement for pip that automatically handles Python versions, virtual environments, and package installation in a single step. You do not need to install Python yourself — uv does it for you.
For Windows Users (Automated):
Install_CorridorKey_Windows.bat. This will automatically install uv (if needed), set up your Python environment, install all dependencies, and download the CorridorKey model.
Note: If this is the first time installing uv, any terminal windows you already had open won't see it. The installer script handles the current window automatically, but if you open a new terminal and get "'uv' is not recognized", just close and reopen that terminal.
Install_GVM_Windows.bat and Install_VideoMaMa_Windows.bat to download the heavy optional Alpha Hint generator weights.For Linux / Mac Users (Automated):
bash. Put a space after writing bash.Install_CorridorKey_Linux_Mac.sh into the terminal. Then press enter.Install_GVM_Linux_Mac.sh and Install_VideoMaMa_Linux_Mac.sh to download the heavy optional Alpha Hint generator weights.For Linux / Mac Users (Manual):
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync # CPU/MPS (default — works everywhere)
uv sync --extra cuda # CUDA GPU acceleration (Linux/Windows)
uv sync --extra mlx # Apple Silicon MLX acceleration
For AMD ROCm setup, see the AMD ROCm Setup section below.CorridorKeyModule/checkpoints/, the engine fetches it from CorridorKey's HuggingFace and saves it as CorridorKey_v1.0.safetensors (preferred — safer, no pickle). Legacy .pth files are still loaded automatically if already present. No manual download needed.--screen-color blue (or when auto-detection picks blue) from CorridorKeyBlue's HuggingFace, saved as CorridorKeyBlue_1.0.safetensors. The two models coexist in checkpoints/ and are picked automatically per clip.uv run hf download geyongtao/gvm --local-dir gvm_core/weightsuv run hf download SammyLim/VideoMaMa --local-dir VideoMaMaInferenceModule/checkpoints/VideoMaMa
uv run hf download stabilityai/stable-video-diffusion-img2vid-xt \
--local-dir VideoMaMaInferenceModule/checkpoints/stable-video-diffusion-img2vid-xt \
--include "feature_extractor/*" "image_encoder/*" "vae/*" "model_index.json"
CorridorKey requires two inputs to process a frame:
By default the screen color is auto-detected from the first frame's background pixels (where the alpha hint is dark). Pass --screen-color green or --screen-color blue to skip detection and force a specific checkpoint.
I've had the best results using GVM or VideoMaMa to create the AlphaHint, so I've repackaged those projects and integrated them here as optional modules inside clip_manager.py. Here is how they compare:
VideoMamaMaskHint/ folder that the wizard creates for your shot. VideoMaMa results are spectacular and can be controlled more easily than GVM due to this mask hint.Perhaps in the future, I will implement other generators for the AlphaHint! In the meantime, the better your Alpha Hint, the better CorridorKey's final result will be. Experiment with different amounts of mask erosion or feathering. The model was trained on coarse, blurry, eroded masks, and is exceptional at filling in details from the hint. However, it is generally less effective at subtracting unwanted mask details if your Alpha Hint is expanded too far.
Please give feedback and share your results!
If you prefer not to install dependencies locally, you can run CorridorKey in Docker.
Prerequisites:
nvidia-smi should work on host, and docker run --rm --gpus all nvidia/cuda:12.6.3-runtime-ubuntu22.04 nvidia-smi should succeed).docker build -t corridorkey:latest .
docker run --rm -it --gpus all \
-e OPENCV_IO_ENABLE_OPENEXR=1 \
-v "$(pwd)/ClipsForInference:/app/ClipsForInference" \
-v "$(pwd)/Output:/app/Output" \
-v "$(pwd)/CorridorKeyModule/checkpoints:/app/CorridorKeyModule/checkpoints" \
-v "$(pwd)/gvm_core/weights:/app/gvm_core/weights" \
-v "$(pwd)/VideoMaMaInferenceModule/checkpoints:/app/VideoMaMaInferenceModule/checkpoints" \
corridorkey:latest run_inference --device cuda
docker compose build
docker compose --profile gpu run --rm corridorkey run_inference --device cuda
docker compose --profile gpu run --rm corridorkey list
docker compose --profile cpu run --rm corridorkey-cpu run_inference --device cpu
NVIDIA_VISIBLE_DEVICES=0 docker compose --profile gpu run --rm corridorkey list
NVIDIA_VISIBLE_DEVICES=1,2 docker compose --profile gpu run --rm corridorkey run_inference --device cuda
Notes:
docker run --rm -it --gpus all \
-e OPENCV_IO_ENABLE_OPENEXR=1 \
-v "$(pwd)/ClipsForInference:/app/ClipsForInference" \
-v "$(pwd)/Output:/app/Output" \
-v "$(pwd)/CorridorKeyModule/checkpoints:/app/CorridorKeyModule/checkpoints" \
-v "$(pwd)/gvm_core/weights:/app/gvm_core/weights" \
-v "$(pwd)/VideoMaMaInferenceModule/checkpoints:/app/VideoMaMaInferenceModule/checkpoints" \
corridorkey:latest wizard --win_path /app/ClipsForInference
docker compose --profile gpu run --rm corridorkey wizard --win_path /app/ClipsForInference
For the easiest experience, use the provided launcher scripts. These scripts launch a prompt-based configuration wizard in your terminal.
CorridorKey_DRAG_CLIPS_HERE_local.bat (Note: Only launch via Drag-and-Drop or CMD. Double-clicking the .bat directly will throw an error)../CorridorKey_DRAG_CLIPS_HERE_local.sh.bash again in terminal. Put a space after and then drag-and-drop CorridorKey_DRAG_CLIPS_HERE_local.sh and your clip folder together into terminal, respectively. Then press enter.Workflow Steps:
.mp4), a shot folder containing image sequences, or even a master "batch" folder containing multiple different shots all at once onto the launcher script.Input/ sub-folder, and generate empty AlphaHint/ and VideoMamaMaskHint/ folders for you. This structure is required for the engine to pair your hints and footage correctly!AlphaHint, it will ask if you want to generate them automatically using the repackaged GVM or VideoMaMa modules./Matte: The raw Linear Alpha channel (EXR)./FG: The raw Straight Foreground Color Object. (Note: The engine natively computes this in the sRGB gamut. You must manually convert this pass to linear gamma before being combined with the alpha in your compositing program)./Processed: An RGBA image containing the Linear Foreground premultiplied against the Linear Alpha (EXR). This pass exists so you can immediately drop the footage into Premiere/Resolve for a quick preview without dealing with complex premultiplication routing. However, if you want more control over your image, working with the raw FG and Matte outputs will give you that./Comp: A simple preview of the key composited over a checkerboard (PNG).If enough people find this project interesting I'll get the training program and datasets uploaded so we can all really go to town making the absolute best keyer fine tunes! Just hit me with some messages on the Corridor Creates discord or here. If enough people lock in, I'll get this stuff packaged up. Hardware requirements are beefy and the gigabytes are plentiful so I don't want to commit the time unless there's demand.
By default, CorridorKey auto-detects the best available compute device: CUDA > MPS > CPU.
Override via CLI flag:
uv run python clip_manager.py --action wizard --win_path "V:\..." --device mps
uv run python clip_manager.py --action run_inference --device cpu
Override via environment variable:
export CORRIDORKEY_DEVICE=cpu
uv run python clip_manager.py --action wizard --win_path "V:\..."
Priority: --device flag > CORRIDORKEY_DEVICE env var > auto-detect.
Confirm MPS is active: Run with verbose logging to see which device was selected:
uv run python clip_manager.py --action list 2>&1 | grep -i "device\|backend\|mps"
MPS operator errors (NotImplementedError: ... not implemented for 'MPS'): Some PyTorch operations are not yet supported on MPS. Enable CPU fallback for those ops:
export PYTORCH_ENABLE_MPS_FALLBACK=1
uv run python corridorkey_cli.py wizard --win_path "/path/to/clips"
Silent CPU fallback: If MPS silently falls back to CPU without this variable, the run will be much slower. Setting PYTORCH_ENABLE_MPS_FALLBACK=1 in your shell profile (~/.zshrc) ensures it is always active.
Use native MLX instead of PyTorch MPS: MLX avoids PyTorch's MPS layer entirely and typically runs faster on Apple Silicon. See the Backend Selection section below for setup steps.
CorridorKey supports AMD GPUs via PyTorch's ROCm/HIP backend. The torch.cuda.* API works transparently on AMD — HIP intercepts all CUDA calls at runtime, so the inference code runs unchanged.
Supported GPUs (ROCm 7.2+):
VRAM requirements: CorridorKey inference at 2048x2048 uses ~10GB on NVIDIA but ~18GB on AMD due to HIP allocator overhead. The RX 7900 XTX (24GB) and RX 7900 XT (20GB) run at full resolution. Cards with 16GB (RX 7800 XT, 9070 XT) work on Windows (which uses system RAM as overflow) but may OOM on Linux — see notes below.
Linux native (recommended):
uv sync --extra rocm
# Verify
uv run python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
WSL2 (Windows Subsystem for Linux):
Requires AMD Adrenalin 26.1.1+ driver on Windows. Install ROCm inside WSL2, then use AMD's WSL-specific torch wheels:
# 1. Install ROCm for WSL (Ubuntu 24.04)
sudo apt update
wget https://repo.radeon.com/amdgpu-install/7.2/ubuntu/noble/amdgpu-install_7.2.70200-1_all.deb
sudo apt install ./amdgpu-install_7.2.70200-1_all.deb
amdgpu-install -y --usecase=wsl,rocm --no-dkms
# 2. Verify GPU is visible
rocminfo # should show your AMD GPU
# 3. Install AMD's WSL torch wheels (Python 3.12)
pip3 install \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp312-cp312-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp312-cp312-linux_x86_64.whl
# 4. Fix WSL runtime library conflict (required)
location=$(pip3 show torch | grep Location | awk -F ": " '{print $2}')
rm -f ${location}/torch/lib/libhsa-runtime64.so*
# 5. Install CorridorKey deps AFTER torch (so pip doesn't overwrite ROCm torch)
pip3 install -e .
Windows native (experimental):
Windows ROCm requires Python 3.12 and AMD Adrenalin 25.3.1+ driver. torch.compile does not work on Windows ROCm — inference runs in eager mode (significantly slower than Linux).
py -3.12 -m pip install https://repo.radeon.com/rocm/windows/rocm-rel-7.2/rocm-7.2.0.dev0-py3-none-win_amd64.whl
py -3.12 -m pip install --no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torch-2.9.1+rocmsdk20260116-cp312-cp312-win_amd64.whl https://repo.radeon.com/rocm/windows/rocm-rel-7.2/torchvision-0.24.1+rocmsdk20260116-cp312-cp312-win_amd64.whl
What CorridorKey does automatically on ROCm:
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 so SDPA dispatches to flash attention kernels on RDNA3 (without this, attention falls back to a slow O(n²) path)MIOPEN_FIND_MODE=2 for faster convolution kernel selection (reduces warmup from 5-8 minutes to seconds)torch.compile(mode="default") on Linux to avoid OOM during kernel autotuning on 16GB cardstorch.compile entirely on Windows ROCm where Triton compilation hangs/opt/rocm (Linux), HIP_PATH (Windows), or CORRIDORKEY_ROCM=1 env var (explicit opt-in)First-run note: The first inference run on a new AMD GPU triggers Triton kernel autotuning (10-20 minutes). This is cached in ~/.cache/corridorkey/inductor/ and only happens once per GPU architecture. Subsequent runs start instantly.
16GB cards on Linux: CorridorKey at 2048x2048 needs ~18GB. Windows handles this transparently via shared GPU memory (system RAM overflow). On Linux, the GPU has a hard VRAM limit. If you hit OOM on a 16GB card, install pytorch-rocm-gtt to enable GTT (system RAM as GPU overflow) — CorridorKey detects and uses it automatically:
pip install pytorch-rocm-gtt
GTT memory is accessed over PCIe (~10-20x slower than VRAM), so expect slower frame times on 16GB cards vs 20-24GB cards.
WSL2 limitation: WSL2 cannot use GTT or shared memory — it has a hard VRAM limit. 16GB cards will OOM in WSL2 at 2048x2048. Use Windows native instead, or a card with 20GB+ VRAM.
CorridorKey supports two inference backends:
Resolution: --backend flag > CORRIDORKEY_BACKEND env var > auto-detect.
Auto mode prefers MLX on Apple Silicon when available.
Override via CLI flag (corridorkey_cli.py):
uv run python corridorkey_cli.py wizard --win_path "/path/to/clips" --backend mlx
uv run python corridorkey_cli.py run_inference --backend torch
Install the MLX backend:
uv sync --extra mlx
Obtain the MLX weights (.safetensors) — pick one option:
Option A — Download pre-converted weights (simplest):
# Download weights from GitHub Releases into a local cache directory
uv run python -m corridorkey_mlx weights download
# Print the cached path, then copy to the checkpoints folder
WEIGHTS=$(uv run python -m corridorkey_mlx weights download --print-path)
cp "$WEIGHTS" CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
Option B — Convert from an existing .pth checkpoint:
# Clone the MLX repo (contains the conversion script)
git clone https://github.com/nikopueringer/corridorkey-mlx.git
cd corridorkey-mlx
uv sync
# Convert (point --checkpoint at your CorridorKey.pth)
uv run python scripts/convert_weights.py \
--checkpoint ../CorridorKeyModule/checkpoints/CorridorKey_v1.0.pth \
--output ../CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
cd ..
Re-publishing the Torch-side official
.safetensors: usescripts/convert_pth_to_safetensors.pyin this repo. It strips the_orig_mod.prefix, contiguises tensors, and verifies the round-trip.
Either way the final file must be at:
CorridorKeyModule/checkpoints/corridorkey_mlx.safetensors
Run with auto-detection or explicit backend:
CORRIDORKEY_BACKEND=mlx uv run python clip_manager.py --action run_inference
MLX uses img_size=2048 by default (same as Torch).
CorridorKeyModule/checkpoints/uv sync --extra mlxCORRIDORKEY_BACKEND=mlx explicitlyFor developers looking for more details on the specifics of what is happening in the CorridorKey engine, check out the README in the /CorridorKeyModule folder. We also have a dedicated handover document outlining the pipeline architecture for AI assistants in /docs/LLM_HANDOVER.md.
You can also explore the full, auto-generated codebase documentation on DeepWiki.
The project includes unit tests for the color math and compositing pipeline. No GPU or model weights required — tests run in a few seconds on any machine.
uv sync --group dev # install test dependencies (pytest)
uv run pytest # run all tests
uv run pytest -v # verbose output (shows each test name)
Use this tool for whatever you'd like, including for processing images as part of a commercial project! You MAY NOT repackage this tool and sell it, and any variations or improvements of this tool that are released must remain under the same license, and must include the name Corridor Key.
You MAY NOT offer inference with this model as a paid API service. If you run a commercial software package or inference service and wish to incoporate this tool into your software, shoot us an email to work out an agreement! I promise we're easy to work with. contact@corridordigital.com. Outside of the stipulations listed above, this license is effectively a variation of Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)
Please keep the Corridor Key name in any future forks or releases!
CorridorKey integrates several open-source modules for Alpha Hint generation. We would like to explicitly credit and thank the following research teams:
gvm_core module. Their work is licensed under the 2-clause BSD License (BSD-2-Clause). You can find their source repository here: aim-uofa/GVM. Give them a star!VideoMaMaInferenceModule. Their code is released under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0), and their specific foundation model checkpoints (dino_projection_mlp.pth, unet/*) are subject to the Stability AI Community License. You can find their source repository here: cvlab-kaist/VideoMaMa. Give them a star!By using these optional modules, you agree to abide by their respective Non-Commercial licenses. Please review their repositories for full terms.
(top 30 of 34)
Python
97.5%
Shell
1.3%
Batchfile
1.0%