feat: RIFE and FILM frame interpolation model support (CORE-29)#13258
feat: RIFE and FILM frame interpolation model support (CORE-29)#13258kijai wants to merge 3 commits intoComfy-Org:masterfrom
Conversation
📝 WalkthroughWalkthroughThis PR adds frame interpolation to Comfy: a new extension registers two nodes ( 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@comfy_extras/nodes_frame_interpolation.py`:
- Around line 107-110: The padding call on frames using F.pad with
mode="reflect" can fail when pad_h >= H or pad_w >= W (e.g., 16×64 or 32×32);
update the logic around pad_h/pad_w calculation so that before calling F.pad you
choose mode = "reflect" if pad_h < H and pad_w < W, otherwise use mode =
"replicate" (or another non-reflect fallback) and pass that mode into
F.pad(frames, (0, pad_w, 0, pad_h), mode=mode) so the function (and the
variables pad_h, pad_w, H, W and the F.pad call) handles small-frame cases
safely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b9519d0a-33fd-4ed3-8b9b-b8a2b44211ad
📒 Files selected for processing (4)
comfy_extras/nodes_frame_interpolation.pycomfy_extras/rife_model/ifnet.pyfolder_paths.pynodes.py
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@comfy_extras/nodes_frame_interpolation.py`:
- Around line 161-167: The multi_fn branch (where multi_fn is used to compute
mids in forward_multi_timestep()) currently asks for all timestep outputs at
once and bypasses the OOM-aware batch-halving fallback; update this branch to
catch CUDA OOM (or memory errors) from multi_fn/forward_multi_timestep and retry
by splitting t_values into smaller chunks (e.g., half the size repeatedly) and
calling multi_fn/forward_multi_timestep per-chunk, copying each chunk into
result as done now, using the same dtype/non_blocking logic and pbar/tqdm
updates; ensure you clear caches between retries (feat_cache or
torch.cuda.empty_cache()) and propagate the original error if even single-step
chunks fail.
- Around line 151-189: The inference loop currently calls inference_model and
inference_model.extract_features while only setting eval(), which still builds
autograd graphs and retains tensors in feat_cache; wrap the loop that iterates
over frame pairs (the try: for i in range(total_pairs): ... finally:) in
torch.inference_mode() so all calls to extract_features, inference_model(...)
and multi_fn(...) run without tracking gradients, preventing unnecessary graph
retention and reducing memory/OOM issues; update any context usage around
feat_cache, multi_fn, and inference_model to execute inside the inference_mode
block.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 43f05f12-4f18-425e-bfd3-3376c4458e9f
📒 Files selected for processing (3)
comfy_extras/frame_interpolation_models/film_net.pycomfy_extras/frame_interpolation_models/ifnet.pycomfy_extras/nodes_frame_interpolation.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@comfy_extras/nodes_frame_interpolation.py`:
- Around line 168-180: The OOM fallback in the multi_fn branch incorrectly uses
"continue", which skips writing outputs for the current pair (variables:
multi_fn, result, out_idx, num_interp) and moves to the next pair; instead,
catch model_management.OOM_EXCEPTION, call model_management.soft_empty_cache(),
set multi_fn = None, and do NOT continue so the loop falls through and retries
the same pair using the single-timestep path (i.e., let the subsequent
single-step interpolation logic run for the current i rather than skipping it).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e695b624-086d-4151-9510-1abfe96d97d3
📒 Files selected for processing (2)
comfy_extras/frame_interpolation_models/film_net.pycomfy_extras/nodes_frame_interpolation.py
Adds pytorch only optimized support for RIFE (MIT) and FILM (Apache 2.0) video frame interpolation models:
https://huggingface.co/Comfy-Org/frame_interpolation/tree/main/frame_interpolation
Optional (advanced) torch.compile option is mostly for FILM since it's a considerable speedup.