A Griptape Nodes library for neural-network green/blue screen keying using CorridorKey.
This library wraps CorridorKey, a transformer-based chroma keying tool built by Niko Pueringer / Corridor Digital for professional VFX pipelines. Given an RGB frame and an optional coarse alpha hint, CorridorKey produces a clean straight (unpremultiplied) alpha matte, a despilled foreground with the screen color removed, a linear premultiplied RGBA matte for compositing, and an optional checkerboard composite preview.
The library exposes two nodes: CorridorKey Inference, which handles the full pipeline on a single image frame (when no alpha hint is supplied it runs BiRefNet internally to generate one, then runs the CorridorKey GreenFormer (Hiera + refiner) keying network with the green-screen or blue-screen checkpoint), and CorridorKey Video Inference, which runs the same per-frame pipeline natively across a video clip or image sequence, with BiRefNet, GVM, or VideoMaMa as the source of the per-frame alpha hint. All weights auto-download from HuggingFace on first use.
gvm and videomama hint sources are only tested on CUDA GPUs with ~80 GB VRAM on a single GPU (no multi-GPU VRAM pooling); birefnet (the default hint source) works on any GPU including Apple Silicon.Runs the full CorridorKey neural keying pipeline on a single image frame. If alpha_hint is left empty, BiRefNet is used internally to generate a coarse hint from the source image.
Parameters:
| Parameter | Type | Description |
|---|---|---|
model | HuggingFace repo | CorridorKey checkpoint to load (nikopueringer/CorridorKey_v1.0 for green, nikopueringer/CorridorKeyBlue_1.0 for blue). |
birefnet_model | HuggingFace repo | BiRefNet variant used to auto-generate an alpha hint when alpha_hint is not provided. Matting variants are best for soft-edge subjects (hair/fur); the general model is better for hard-edged objects. Ignored if alpha_hint is supplied. |
image | ImageUrlArtifact | RGB source frame. Any resolution; internally resized to img_size for inference and upsampled back. |
alpha_hint | ImageUrlArtifact (optional) | Optional coarse alpha-hint mask, 0=background 1=foreground. If left empty, BiRefNet is run internally to generate the hint. |
img_size | int | Inference resolution (square). 2048 matches the trained resolution; lower values are faster but less accurate. (default: 2048) |
input_is_linear | bool | If True, the input image is treated as linear and resized in linear before being converted to sRGB for the model. Leave False for typical sRGB inputs. (default: false) |
fg_is_straight | bool | If True, the foreground output is straight (unpremultiplied). Leave True for the published checkpoints. (default: true) |
despill_strength | float | 0.0-1.0 multiplier for the despill pass that removes screen-color contamination from the foreground. (default: 1.0) |
auto_despeckle | bool | If True, runs a morphological cleanup that removes small disconnected islands from the predicted matte. (default: true) |
despeckle_size | int | Minimum connected-component size (in pixels) preserved when auto_despeckle is True. (default: 400) |
refiner_scale | float | Multiplier on the refiner head's delta contribution. 1.0 = default, >1.0 sharpens edges, 0.0 disables the refiner. (default: 1.0) |
generate_comp | bool | If True, also produces a composite-on-gray-checkerboard preview. (default: true) |
alpha | ImageUrlArtifact (output) | Single-channel straight alpha matte (float 0-1) encoded as a grayscale PNG. |
foreground | ImageUrlArtifact (output) | Despilled sRGB foreground, straight (unpremultiplied), encoded as PNG. |
composite | ImageUrlArtifact (output) | sRGB composite of the foreground over a gray checkerboard (PNG). None when generate_comp is False. |
rgba | ImageUrlArtifact (output) | Linear premultiplied RGBA (foreground * alpha, plus alpha channel) encoded as an 8-bit PNG with alpha for use as a drop-in matte. |
Runs the full CorridorKey neural keying pipeline across every frame of a video clip or image sequence. The per-frame alpha hint is generated by one of three sources, selected via hint_source:
birefnet (default): BiRefNet runs independently on each frame. Works on any GPU.gvm: the GVM video model generates temporally-consistent hints across the whole clip in one pass. Only tested on CUDA GPUs with ~80 GB VRAM on a single GPU (the vendored GVMProcessor has no multi-GPU/offload support); on other devices the node warns rather than blocking.videomama: also generates temporally-consistent hints, guided by a rough per-frame mask supplied via mask_hint. Same CUDA/VRAM caveat as GVM.Only the parameters relevant to the current hint_source and output_format selection are shown; the rest are hidden automatically.
Parameters:
| Parameter | Type | Description |
|---|---|---|
video | video / sequence | Source clip to key. Accepts a video file, a Sequence (e.g. from Scan Sequence), a sequence pattern (frame.####.exr), a directory, or a list of frame paths. |
model | HuggingFace repo | CorridorKey checkpoint to load, same choices as the image node. |
hint_source | choice | birefnet, gvm, or videomama — see above. (default: birefnet) |
birefnet_model | HuggingFace repo | BiRefNet variant, shown when hint_source is birefnet. |
gvm_model | HuggingFace repo | GVM checkpoint, shown when hint_source is gvm. |
gvm_num_frames_per_batch | int | GVM only: number of frames per inference batch when generating temporal alpha hints. (default: 8) |
gvm_num_overlap_frames | int | GVM only: number of overlapping frames between consecutive batches, for temporal smoothness. (default: 1) |
gvm_denoise_steps | int | GVM only: number of diffusion denoising steps used to generate each alpha-hint batch. (default: 1) |
mask_hint | video / sequence | VideoMaMa only, required when hint_source is videomama: a rough per-frame foreground mask, one per video frame, as a video or image sequence. |
videomama_unet_model | HuggingFace repo | VideoMaMa UNet checkpoint, shown when hint_source is videomama. |
videomama_base_model | HuggingFace repo | Base stable-video-diffusion checkpoint VideoMaMa builds on, shown when hint_source is videomama. |
videomama_chunk_size | int | VideoMaMa only: number of frames processed per diffusion call, to bound VRAM usage. (default: 24) |
output_frame_rate | float | Frame rate for video outputs when the source is an image sequence (no inherent frame rate). Ignored for a video-file source, which uses its own frame rate. (default: 24.0) |
max_frames | int | Cap on the number of frames processed, useful for previewing a long clip. 0 = process all frames. (default: 0) |
batch_size | int | Number of frames sent through the CorridorKey engine per inference call. (default: 4) |
img_size | int | Inference resolution (square), same meaning as the image node. (default: 2048) |
input_is_linear | bool | Same meaning as the image node. (default: false) |
fg_is_straight | bool | Same meaning as the image node. (default: true) |
despill_strength | float | Same meaning as the image node. (default: 1.0) |
auto_despeckle | bool | Same meaning as the image node. (default: true) |
despeckle_size | int | Same meaning as the image node. (default: 400) |
refiner_scale | float | Same meaning as the image node. (default: 1.0) |
generate_comp | bool | Same meaning as the image node. (default: true) |
output_format | choice | video writes alpha/foreground/composite as mp4 (no alpha channel possible). exr_sequence writes each as a float32 EXR image sequence instead, which can carry a genuine alpha channel. (default: video) |
alpha | VideoUrlArtifact (output) | Alpha matte video (grayscale mp4). Populated when output_format is video. |
foreground | VideoUrlArtifact (output) | Despilled sRGB foreground video. Populated when output_format is video. |
composite | VideoUrlArtifact (output) | Composite-on-checkerboard preview video. Populated when output_format is video and generate_comp is true. |
alpha_sequence | Sequence (output) | Alpha matte as an EXR sequence. Populated when output_format is exr_sequence. |
foreground_sequence | Sequence (output) | Despilled sRGB foreground as an EXR sequence. Populated when output_format is exr_sequence. |
composite_sequence | Sequence (output) | Composite-on-checkerboard as an EXR sequence. Populated when output_format is exr_sequence and generate_comp is true. |
The following models are available from HuggingFace:
| Model | Description |
|---|---|
nikopueringer/CorridorKey_v1.0 | Primary green-screen keying weights (~300 MB). GreenFormer with a Hiera-Base-Plus backbone and refiner head. |
nikopueringer/CorridorKeyBlue_1.0 | Blue-screen keying weights (~300 MB). Identical architecture to the green checkpoint; only the trained weights differ. |
ZhengPeng7/BiRefNet-matting | BiRefNet image-matting weights, used when no alpha hint is supplied. Best for soft-edge subjects (hair, fur). |
ZhengPeng7/BiRefNet | BiRefNet general-purpose segmentation weights, used when no alpha hint is supplied. Better for hard-edged objects. |
geyongtao/gvm | GVM video-matting weights, used by CorridorKey Video Inference when hint_source is gvm to generate temporally-consistent alpha hints across a clip. Large download; only tested on CUDA GPUs with ~80 GB VRAM. |
SammyLim/VideoMaMa | VideoMaMa UNet weights, used by CorridorKey Video Inference when hint_source is videomama. Large download; same CUDA/VRAM caveat as GVM. |
stabilityai/stable-video-diffusion-img2vid-xt | Base stable-video-diffusion checkpoint VideoMaMa builds on. Downloaded alongside the VideoMaMa UNet weights. |
Models are downloaded automatically on first use and cached for subsequent runs. The CorridorKey checkpoints land under <site-packages>/CorridorKeyModule/checkpoints/; the BiRefNet weights land under <site-packages>/BiRefNetModule/checkpoints/<repo_name>/; GVM and VideoMaMa weights are resolved from the standard HuggingFace hub cache (~/.cache/huggingface/hub/ by default).
pip_dependencies in the library JSON is the edit-time set, installed wherever the library is registered, and holds only what importing and instantiating a node needs. pip_dependencies_exec is the ML stack, installed into .venv-exec, which only the worker process that runs a node ever reads. On top of that, the advanced library installs the pinned CorridorKey submodule itself with --no-deps into the same .venv-exec, because BiRefNetModule is absent from the wheel's package list and is reached through sys.path rather than installed.
Clone the repository to your Griptape Nodes workspace directory:
cd `gtn config show workspace_directory`
git clone --recurse-submodules https://github.com/griptape-ai/griptape-nodes-library-corridorkey.git
Add the library in the Griptape Nodes Editor:
<workspace_directory>/griptape-nodes-library-corridorkey/griptape_nodes_library_corridorkey/griptape-nodes-library.json
gtn config show workspace_directoryVerify installation by checking that the CorridorKey Inference and CorridorKey Video Inference nodes appear in the node palette under the "CorridorKey" category.
image. The node accepts any resolution; the source is resized internally to img_size for inference and upsampled back to its original resolution.model: nikopueringer/CorridorKey_v1.0 for green screens, nikopueringer/CorridorKeyBlue_1.0 for blue screens.alpha_hint mask if you have one. If you leave it empty, the node will run BiRefNet on image to generate the hint automatically; pick the BiRefNet variant via birefnet_model (matting for soft edges, general for hard edges).despill_strength, auto_despeckle, despeckle_size, and refiner_scale to control the despill pass, matte cleanup, and refiner head.alpha, foreground, composite, or rgba to your downstream nodes:
alpha is the cleaned matte for use in compositingforeground is the despilled sRGB platergba is an 8-bit linear premultiplied RGBA matte ready to drop into a compositorcomposite is a quick checkerboard preview for sanity-checking the matteThe first run will download the selected CorridorKey checkpoint (~300 MB) and, if used, the BiRefNet weights (varies by variant). On Linux/Windows with a C compiler installed, CorridorKey also performs a one-time torch.compile pass that adds 30 s - 20 min to the first call; subsequent calls reuse the autotune cache under ~/.cache/corridorkey/inductor/.
video: a video file, a Sequence, a directory of frames, a sequence pattern (frame.####.exr), or a list of frame paths.model, same as the image node.hint_source:
birefnet (default) — pick the variant via birefnet_model, same as the image node. Works on any GPU.gvm — pick the checkpoint via gvm_model; tune gvm_num_frames_per_batch, gvm_num_overlap_frames, and gvm_denoise_steps if needed. Requires a CUDA GPU with ~80 GB VRAM.videomama — connect a rough per-frame foreground mask to mask_hint, and pick the checkpoints via videomama_unet_model/videomama_base_model. Requires a CUDA GPU with ~80 GB VRAM.output_format: video for mp4 outputs (alpha/foreground/composite), or exr_sequence for a float32 EXR sequence per output (alpha_sequence/foreground_sequence/composite_sequence) if you need a genuine alpha channel.img_size, batch_size, despill_strength, auto_despeckle, despeckle_size, and refiner_scale as with the image node. Use max_frames to cap processing while previewing a long clip, and output_frame_rate to set the frame rate for outputs when the source is an image sequence.output_format) to your downstream nodes.The first run of gvm or videomama will download their (large) checkpoints through Griptape Nodes' Model Manager, with visible progress in the UI.
CorridorKey vendors a third-party engine (CorridorKeyModule) and depends on timm for its Hiera backbone. On load, corridorkey_common.py applies two runtime patches (in-process only, idempotent, no installed files are modified) to work around upstream bugs that otherwise only surface on Apple Silicon (MPS):
.view() → .reshape() (_patch_timm_hiera_view_bug): timm's hiera_base_plus_224 backbone's MaskUnitAttention.forward() calls .view() on a tensor produced by a preceding .permute(), which raises "view size is not compatible with input tensor's size and stride" on MPS (the stride layout that triggers it doesn't come up on CPU/CUDA). Patches the forward pass to use .reshape() instead (a drop-in replacement that only copies when a view isn't possible), and makes q/k/v contiguous before scaled_dot_product_attention, which does its own internal .view() on its inputs.connected_components MPS race (_patch_connected_components_mps_race): the despeckle pass's connected_components() (in the vendored CorridorKeyModule.core.color_utils) writes and reads its flood-fill buffer via boolean advanced indexing (comp[mask == 1] = pooled[mask == 1]). On MPS, the scatter and gather sides each trigger their own async nonzero-count kernel invocation, and the two occasionally disagree on the mask's true-count even given the same mask tensor — an indexing-kernel race, not a mask-recomputation issue, so hoisting the mask evaluation out of the loop doesn't fix it. Patched to use torch.where (an elementwise select with no variable-length indexing step) instead, which removes the race entirely (the race's documented symptom is a RuntimeError: shape mismatch crash inside connected_components, not silent data corruption).Also investigated, separate from the two patches above: on some Apple Silicon Macs, the very first CorridorKey Inference/CorridorKey Video Inference call in a freshly-started engine process was once observed to return fully-NaN alpha/foreground/rgba (visibly all-black output), regardless of auto_despeckle, with every subsequent call in the same process reliable. Follow-up testing -- a synthetic repro against the real checkpoint at several resolutions, plus a fresh end-to-end run in the desktop app at the production default img_size=2048 on a newly-launched engine -- could not reproduce it, and ruled out the originally-suspected mechanism: production never actually runs the model under torch.autocast on fp32 weights (CorridorKeyEngine disables mixed precision whenever model_precision=torch.float16, which it always is in practice, so the forward pass runs native fp16 end-to-end). Current best guess is a one-off cold macOS/Metal shader-compilation cache artifact on that machine rather than a reliably-reproducing bug -- if you ever hit a fully black result on a first run, re-run the node; it has not recurred in testing since.
--recurse-submodules, run:
git submodule update --init --recursive
nvidia-smi reports your GPU correctly/opt/rocm exists (Linux only)img_size (e.g., from 2048 to 1024). The 2048 default matches the trained resolution; lower values run faster and use less VRAM at the cost of fine-edge accuracy.batch_size on CorridorKey Video Inference to lower peak VRAM usage for the keying pass itself.gvm and videomama hint sources need ~80 GB VRAM on a single CUDA GPU; if that's not available, use hint_source=birefnet instead, which works on any GPU with the same VRAM budget as the image node.torch.compile on the first process_frame call to autotune kernels for the active GPU. This adds 30 s - 20 min depending on the backend. The autotune cache is persisted under ~/.cache/corridorkey/inductor/ and reused on subsequent runs.CORRIDORKEY_SKIP_COMPILE=1 before launching the engine.This library is distributed under the Corridor Key Licence (Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International, with the Corridor Key Additional Terms and Conditions). This matches the license of the upstream CorridorKey project, as required by the share-alike clause of that licence. See the LICENSE file in this repository for the full text.
The "CorridorKey" name and any associated trademarks remain the property of Corridor Digital.
A Griptape Nodes library for neural-network green/blue screen keying using CorridorKey.
This library wraps CorridorKey, a transformer-based chroma keying tool built by Niko Pueringer / Corridor Digital for professional VFX pipelines. Given an RGB frame and an optional coarse alpha hint, CorridorKey produces a clean straight (unpremultiplied) alpha matte, a despilled foreground with the screen color removed, a linear premultiplied RGBA matte for compositing, and an optional checkerboard composite preview.
The library exposes two nodes: CorridorKey Inference, which handles the full pipeline on a single image frame (when no alpha hint is supplied it runs BiRefNet internally to generate one, then runs the CorridorKey GreenFormer (Hiera + refiner) keying network with the green-screen or blue-screen checkpoint), and CorridorKey Video Inference, which runs the same per-frame pipeline natively across a video clip or image sequence, with BiRefNet, GVM, or VideoMaMa as the source of the per-frame alpha hint. All weights auto-download from HuggingFace on first use.
gvm and videomama hint sources are only tested on CUDA GPUs with ~80 GB VRAM on a single GPU (no multi-GPU VRAM pooling); birefnet (the default hint source) works on any GPU including Apple Silicon.Runs the full CorridorKey neural keying pipeline on a single image frame. If alpha_hint is left empty, BiRefNet is used internally to generate a coarse hint from the source image.
Parameters:
| Parameter | Type | Description |
|---|---|---|
model | HuggingFace repo | CorridorKey checkpoint to load (nikopueringer/CorridorKey_v1.0 for green, nikopueringer/CorridorKeyBlue_1.0 for blue). |
birefnet_model | HuggingFace repo | BiRefNet variant used to auto-generate an alpha hint when alpha_hint is not provided. Matting variants are best for soft-edge subjects (hair/fur); the general model is better for hard-edged objects. Ignored if alpha_hint is supplied. |
image | ImageUrlArtifact | RGB source frame. Any resolution; internally resized to img_size for inference and upsampled back. |
alpha_hint | ImageUrlArtifact (optional) | Optional coarse alpha-hint mask, 0=background 1=foreground. If left empty, BiRefNet is run internally to generate the hint. |
img_size | int | Inference resolution (square). 2048 matches the trained resolution; lower values are faster but less accurate. (default: 2048) |
input_is_linear | bool | If True, the input image is treated as linear and resized in linear before being converted to sRGB for the model. Leave False for typical sRGB inputs. (default: false) |
fg_is_straight | bool | If True, the foreground output is straight (unpremultiplied). Leave True for the published checkpoints. (default: true) |
despill_strength | float | 0.0-1.0 multiplier for the despill pass that removes screen-color contamination from the foreground. (default: 1.0) |
auto_despeckle | bool | If True, runs a morphological cleanup that removes small disconnected islands from the predicted matte. (default: true) |
despeckle_size | int | Minimum connected-component size (in pixels) preserved when auto_despeckle is True. (default: 400) |
refiner_scale | float | Multiplier on the refiner head's delta contribution. 1.0 = default, >1.0 sharpens edges, 0.0 disables the refiner. (default: 1.0) |
generate_comp | bool | If True, also produces a composite-on-gray-checkerboard preview. (default: true) |
alpha | ImageUrlArtifact (output) | Single-channel straight alpha matte (float 0-1) encoded as a grayscale PNG. |
foreground | ImageUrlArtifact (output) | Despilled sRGB foreground, straight (unpremultiplied), encoded as PNG. |
composite | ImageUrlArtifact (output) | sRGB composite of the foreground over a gray checkerboard (PNG). None when generate_comp is False. |
rgba | ImageUrlArtifact (output) | Linear premultiplied RGBA (foreground * alpha, plus alpha channel) encoded as an 8-bit PNG with alpha for use as a drop-in matte. |
Runs the full CorridorKey neural keying pipeline across every frame of a video clip or image sequence. The per-frame alpha hint is generated by one of three sources, selected via hint_source:
birefnet (default): BiRefNet runs independently on each frame. Works on any GPU.gvm: the GVM video model generates temporally-consistent hints across the whole clip in one pass. Only tested on CUDA GPUs with ~80 GB VRAM on a single GPU (the vendored GVMProcessor has no multi-GPU/offload support); on other devices the node warns rather than blocking.videomama: also generates temporally-consistent hints, guided by a rough per-frame mask supplied via mask_hint. Same CUDA/VRAM caveat as GVM.Only the parameters relevant to the current hint_source and output_format selection are shown; the rest are hidden automatically.
Parameters:
| Parameter | Type | Description |
|---|---|---|
video | video / sequence | Source clip to key. Accepts a video file, a Sequence (e.g. from Scan Sequence), a sequence pattern (frame.####.exr), a directory, or a list of frame paths. |
model | HuggingFace repo | CorridorKey checkpoint to load, same choices as the image node. |
hint_source | choice | birefnet, gvm, or videomama — see above. (default: birefnet) |
birefnet_model | HuggingFace repo | BiRefNet variant, shown when hint_source is birefnet. |
gvm_model | HuggingFace repo | GVM checkpoint, shown when hint_source is gvm. |
gvm_num_frames_per_batch | int | GVM only: number of frames per inference batch when generating temporal alpha hints. (default: 8) |
gvm_num_overlap_frames | int | GVM only: number of overlapping frames between consecutive batches, for temporal smoothness. (default: 1) |
gvm_denoise_steps | int | GVM only: number of diffusion denoising steps used to generate each alpha-hint batch. (default: 1) |
mask_hint | video / sequence | VideoMaMa only, required when hint_source is videomama: a rough per-frame foreground mask, one per video frame, as a video or image sequence. |
videomama_unet_model | HuggingFace repo | VideoMaMa UNet checkpoint, shown when hint_source is videomama. |
videomama_base_model | HuggingFace repo | Base stable-video-diffusion checkpoint VideoMaMa builds on, shown when hint_source is videomama. |
videomama_chunk_size | int | VideoMaMa only: number of frames processed per diffusion call, to bound VRAM usage. (default: 24) |
output_frame_rate | float | Frame rate for video outputs when the source is an image sequence (no inherent frame rate). Ignored for a video-file source, which uses its own frame rate. (default: 24.0) |
max_frames | int | Cap on the number of frames processed, useful for previewing a long clip. 0 = process all frames. (default: 0) |
batch_size | int | Number of frames sent through the CorridorKey engine per inference call. (default: 4) |
img_size | int | Inference resolution (square), same meaning as the image node. (default: 2048) |
input_is_linear | bool | Same meaning as the image node. (default: false) |
fg_is_straight | bool | Same meaning as the image node. (default: true) |
despill_strength | float | Same meaning as the image node. (default: 1.0) |
auto_despeckle | bool | Same meaning as the image node. (default: true) |
despeckle_size | int | Same meaning as the image node. (default: 400) |
refiner_scale | float | Same meaning as the image node. (default: 1.0) |
generate_comp | bool | Same meaning as the image node. (default: true) |
output_format | choice | video writes alpha/foreground/composite as mp4 (no alpha channel possible). exr_sequence writes each as a float32 EXR image sequence instead, which can carry a genuine alpha channel. (default: video) |
alpha | VideoUrlArtifact (output) | Alpha matte video (grayscale mp4). Populated when output_format is video. |
foreground | VideoUrlArtifact (output) | Despilled sRGB foreground video. Populated when output_format is video. |
composite | VideoUrlArtifact (output) | Composite-on-checkerboard preview video. Populated when output_format is video and generate_comp is true. |
alpha_sequence | Sequence (output) | Alpha matte as an EXR sequence. Populated when output_format is exr_sequence. |
foreground_sequence | Sequence (output) | Despilled sRGB foreground as an EXR sequence. Populated when output_format is exr_sequence. |
composite_sequence | Sequence (output) | Composite-on-checkerboard as an EXR sequence. Populated when output_format is exr_sequence and generate_comp is true. |
The following models are available from HuggingFace:
| Model | Description |
|---|---|
nikopueringer/CorridorKey_v1.0 | Primary green-screen keying weights (~300 MB). GreenFormer with a Hiera-Base-Plus backbone and refiner head. |
nikopueringer/CorridorKeyBlue_1.0 | Blue-screen keying weights (~300 MB). Identical architecture to the green checkpoint; only the trained weights differ. |
ZhengPeng7/BiRefNet-matting | BiRefNet image-matting weights, used when no alpha hint is supplied. Best for soft-edge subjects (hair, fur). |
ZhengPeng7/BiRefNet | BiRefNet general-purpose segmentation weights, used when no alpha hint is supplied. Better for hard-edged objects. |
geyongtao/gvm | GVM video-matting weights, used by CorridorKey Video Inference when hint_source is gvm to generate temporally-consistent alpha hints across a clip. Large download; only tested on CUDA GPUs with ~80 GB VRAM. |
SammyLim/VideoMaMa | VideoMaMa UNet weights, used by CorridorKey Video Inference when hint_source is videomama. Large download; same CUDA/VRAM caveat as GVM. |
stabilityai/stable-video-diffusion-img2vid-xt | Base stable-video-diffusion checkpoint VideoMaMa builds on. Downloaded alongside the VideoMaMa UNet weights. |
Models are downloaded automatically on first use and cached for subsequent runs. The CorridorKey checkpoints land under <site-packages>/CorridorKeyModule/checkpoints/; the BiRefNet weights land under <site-packages>/BiRefNetModule/checkpoints/<repo_name>/; GVM and VideoMaMa weights are resolved from the standard HuggingFace hub cache (~/.cache/huggingface/hub/ by default).
pip_dependencies in the library JSON is the edit-time set, installed wherever the library is registered, and holds only what importing and instantiating a node needs. pip_dependencies_exec is the ML stack, installed into .venv-exec, which only the worker process that runs a node ever reads. On top of that, the advanced library installs the pinned CorridorKey submodule itself with --no-deps into the same .venv-exec, because BiRefNetModule is absent from the wheel's package list and is reached through sys.path rather than installed.
Clone the repository to your Griptape Nodes workspace directory:
cd `gtn config show workspace_directory`
git clone --recurse-submodules https://github.com/griptape-ai/griptape-nodes-library-corridorkey.git
Add the library in the Griptape Nodes Editor:
<workspace_directory>/griptape-nodes-library-corridorkey/griptape_nodes_library_corridorkey/griptape-nodes-library.json
gtn config show workspace_directoryVerify installation by checking that the CorridorKey Inference and CorridorKey Video Inference nodes appear in the node palette under the "CorridorKey" category.
image. The node accepts any resolution; the source is resized internally to img_size for inference and upsampled back to its original resolution.model: nikopueringer/CorridorKey_v1.0 for green screens, nikopueringer/CorridorKeyBlue_1.0 for blue screens.alpha_hint mask if you have one. If you leave it empty, the node will run BiRefNet on image to generate the hint automatically; pick the BiRefNet variant via birefnet_model (matting for soft edges, general for hard edges).despill_strength, auto_despeckle, despeckle_size, and refiner_scale to control the despill pass, matte cleanup, and refiner head.alpha, foreground, composite, or rgba to your downstream nodes:
alpha is the cleaned matte for use in compositingforeground is the despilled sRGB platergba is an 8-bit linear premultiplied RGBA matte ready to drop into a compositorcomposite is a quick checkerboard preview for sanity-checking the matteThe first run will download the selected CorridorKey checkpoint (~300 MB) and, if used, the BiRefNet weights (varies by variant). On Linux/Windows with a C compiler installed, CorridorKey also performs a one-time torch.compile pass that adds 30 s - 20 min to the first call; subsequent calls reuse the autotune cache under ~/.cache/corridorkey/inductor/.
video: a video file, a Sequence, a directory of frames, a sequence pattern (frame.####.exr), or a list of frame paths.model, same as the image node.hint_source:
birefnet (default) — pick the variant via birefnet_model, same as the image node. Works on any GPU.gvm — pick the checkpoint via gvm_model; tune gvm_num_frames_per_batch, gvm_num_overlap_frames, and gvm_denoise_steps if needed. Requires a CUDA GPU with ~80 GB VRAM.videomama — connect a rough per-frame foreground mask to mask_hint, and pick the checkpoints via videomama_unet_model/videomama_base_model. Requires a CUDA GPU with ~80 GB VRAM.output_format: video for mp4 outputs (alpha/foreground/composite), or exr_sequence for a float32 EXR sequence per output (alpha_sequence/foreground_sequence/composite_sequence) if you need a genuine alpha channel.img_size, batch_size, despill_strength, auto_despeckle, despeckle_size, and refiner_scale as with the image node. Use max_frames to cap processing while previewing a long clip, and output_frame_rate to set the frame rate for outputs when the source is an image sequence.output_format) to your downstream nodes.The first run of gvm or videomama will download their (large) checkpoints through Griptape Nodes' Model Manager, with visible progress in the UI.
CorridorKey vendors a third-party engine (CorridorKeyModule) and depends on timm for its Hiera backbone. On load, corridorkey_common.py applies two runtime patches (in-process only, idempotent, no installed files are modified) to work around upstream bugs that otherwise only surface on Apple Silicon (MPS):
.view() → .reshape() (_patch_timm_hiera_view_bug): timm's hiera_base_plus_224 backbone's MaskUnitAttention.forward() calls .view() on a tensor produced by a preceding .permute(), which raises "view size is not compatible with input tensor's size and stride" on MPS (the stride layout that triggers it doesn't come up on CPU/CUDA). Patches the forward pass to use .reshape() instead (a drop-in replacement that only copies when a view isn't possible), and makes q/k/v contiguous before scaled_dot_product_attention, which does its own internal .view() on its inputs.connected_components MPS race (_patch_connected_components_mps_race): the despeckle pass's connected_components() (in the vendored CorridorKeyModule.core.color_utils) writes and reads its flood-fill buffer via boolean advanced indexing (comp[mask == 1] = pooled[mask == 1]). On MPS, the scatter and gather sides each trigger their own async nonzero-count kernel invocation, and the two occasionally disagree on the mask's true-count even given the same mask tensor — an indexing-kernel race, not a mask-recomputation issue, so hoisting the mask evaluation out of the loop doesn't fix it. Patched to use torch.where (an elementwise select with no variable-length indexing step) instead, which removes the race entirely (the race's documented symptom is a RuntimeError: shape mismatch crash inside connected_components, not silent data corruption).Also investigated, separate from the two patches above: on some Apple Silicon Macs, the very first CorridorKey Inference/CorridorKey Video Inference call in a freshly-started engine process was once observed to return fully-NaN alpha/foreground/rgba (visibly all-black output), regardless of auto_despeckle, with every subsequent call in the same process reliable. Follow-up testing -- a synthetic repro against the real checkpoint at several resolutions, plus a fresh end-to-end run in the desktop app at the production default img_size=2048 on a newly-launched engine -- could not reproduce it, and ruled out the originally-suspected mechanism: production never actually runs the model under torch.autocast on fp32 weights (CorridorKeyEngine disables mixed precision whenever model_precision=torch.float16, which it always is in practice, so the forward pass runs native fp16 end-to-end). Current best guess is a one-off cold macOS/Metal shader-compilation cache artifact on that machine rather than a reliably-reproducing bug -- if you ever hit a fully black result on a first run, re-run the node; it has not recurred in testing since.
--recurse-submodules, run:
git submodule update --init --recursive
nvidia-smi reports your GPU correctly/opt/rocm exists (Linux only)img_size (e.g., from 2048 to 1024). The 2048 default matches the trained resolution; lower values run faster and use less VRAM at the cost of fine-edge accuracy.batch_size on CorridorKey Video Inference to lower peak VRAM usage for the keying pass itself.gvm and videomama hint sources need ~80 GB VRAM on a single CUDA GPU; if that's not available, use hint_source=birefnet instead, which works on any GPU with the same VRAM budget as the image node.torch.compile on the first process_frame call to autotune kernels for the active GPU. This adds 30 s - 20 min depending on the backend. The autotune cache is persisted under ~/.cache/corridorkey/inductor/ and reused on subsequent runs.CORRIDORKEY_SKIP_COMPILE=1 before launching the engine.This library is distributed under the Corridor Key Licence (Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International, with the Corridor Key Additional Terms and Conditions). This matches the license of the upstream CorridorKey project, as required by the share-alike clause of that licence. See the LICENSE file in this repository for the full text.
The "CorridorKey" name and any associated trademarks remain the property of Corridor Digital.