TensorForger/RIFE-safetensors
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
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
git clone https://huggingface.co/tensorforger/RIFE-safetensors
cd RIFE-safetensors
pip install -r requirements.txtUsage
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)
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.
python demo.pyOutput shape printed to stdout: torch.Size([1, 3, 256, 256]). A window will open showing frame 0 · interpolated frame · frame 1.
Files
Citation
@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.
