Skip to content

feat: RIFE and FILM frame interpolation model support (CORE-29)#13258

Open
kijai wants to merge 3 commits intoComfy-Org:masterfrom
kijai:rife
Open

feat: RIFE and FILM frame interpolation model support (CORE-29)#13258
kijai wants to merge 3 commits intoComfy-Org:masterfrom
kijai:rife

Conversation

@kijai
Copy link
Copy Markdown
Contributor

@kijai kijai commented Apr 2, 2026

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

image

Optional (advanced) torch.compile option is mostly for FILM since it's a considerable speedup.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

This PR adds frame interpolation to Comfy: a new extension registers two nodes (FrameInterpolationModelLoader, FrameInterpolate) and a custom type FrameInterpolationModel. It introduces FILM and IFNet model implementations, model-loading logic that detects RIFE vs FILM checkpoints, GPU/device and dtype handling, and runtime interpolation code with padding, batching, and OOM mitigation. It also adds a frame_interpolation models folder and updates builtin extra node imports.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.20% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for RIFE and FILM frame interpolation models.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of PyTorch-optimized support for RIFE and FILM frame interpolation models with links and implementation details.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c63b4f and a859152.

📒 Files selected for processing (4)
  • comfy_extras/nodes_frame_interpolation.py
  • comfy_extras/rife_model/ifnet.py
  • folder_paths.py
  • nodes.py

@kijai kijai changed the title feat: RIFE frame interpolation model support feat: RIFE frame interpolation model support (CORE-29) Apr 2, 2026
@kijai kijai changed the title feat: RIFE frame interpolation model support (CORE-29) feat: RIFE and FILM frame interpolation model support (CORE-29) Apr 4, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a859152 and 257c531.

📒 Files selected for processing (3)
  • comfy_extras/frame_interpolation_models/film_net.py
  • comfy_extras/frame_interpolation_models/ifnet.py
  • comfy_extras/nodes_frame_interpolation.py

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 257c531 and 3cbd1d5.

📒 Files selected for processing (2)
  • comfy_extras/frame_interpolation_models/film_net.py
  • comfy_extras/nodes_frame_interpolation.py

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant