CoolFace
Modelpublic

TensorForger/RIFE-safetensors

sourceHugging Facemitupdated 5mo agoView on Hugging Face
2likes144downloads
Model Card

RIFE — Real-Time Intermediate Flow Estimation

Safetensors re-host of the RIFE v4 frame interpolation model from ECCV2022-RIFE (MIT license, © Megvii Inc.).

What is different from the original

OriginalThis repo
Weight format.pkl hosted on Google Drive.safetensors hosted on Hugging Face
TensorRT / `torch.compile`Known issues with torchinductor and TensorRT backendsFixed — model sources are fully compatible

The architectural code in interpolation_model.py is a minimal clean-up of the upstream `model/IFNet.py` with all changes required for torch.compile and TensorRT export applied.

Model description

RIFE (Real-Time Intermediate Flow Estimation) estimates an intermediate video frame between two input frames by computing bidirectional optical flow and blending the warped frames with a learned mask.

Input: a (B, 6, H, W) tensor — the first frame in channels [:3] and the second frame in channels [3:], values in [0, 1]. Output: a (B, 3, H, W) interpolated frame tensor, values in [0, 1].

Installation

bash
git clone https://huggingface.co/tensorforger/RIFE-safetensors
cd RIFE-safetensors
pip install -r requirements.txt

Usage

python
import torch
from safetensors.torch import load_file
from interpolation_model import IFNet

model = IFNet()
model.load_state_dict(load_file("flownet.safetensors"))
model.to("cuda").eval()

# frame0, frame1: (B, 3, H, W) float tensors in [0, 1]
x = torch.cat([frame0, frame1], dim=1)   # → (B, 6, H, W)
with torch.no_grad():
    mid_frame = model(x)                 # → (B, 3, H, W)

torch.compile (torchinductor / TensorRT)

python
model = torch.compile(model, backend="inductor")   # or backend="tensorrt"

Run the bundled demo

The demo generates two synthetic frames with shifted gray squares and displays the interpolated result with matplotlib.

bash
python demo.py

Output shape printed to stdout: torch.Size([1, 3, 256, 256]). A window will open showing frame 0 · interpolated frame · frame 1.

Files

FileDescription
flownet.safetensorsModel weights (converted from original .pkl)
interpolation_model.pyIFNet model definition (compile-friendly fork of upstream)
demo.pyMinimal runnable example
requirements.txtPython dependencies

Citation

bibtex
@inproceedings{huang2022rife,
  title     = {Real-Time Intermediate Flow Estimation for Video Frame Interpolation},
  author    = {Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang},
  booktitle = {Proceedings of the European Conference on Computer Vision (ECCV)},
  year      = {2022}
}

License

MIT — see LICENSE. Original work © Megvii Inc. This re-host adds no new restrictions.