PyTorch
Safetensors
TensorRT
custom
video-interpolation
frame-interpolation
optical-flow
torch-compile
Instructions to use TensorForger/RIFE-safetensors with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TensorRT
How to use TensorForger/RIFE-safetensors with TensorRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 3,185 Bytes
3cf1416 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | ---
license: mit
tags:
- video-interpolation
- frame-interpolation
- optical-flow
- pytorch
- safetensors
- tensorrt
- torch-compile
library_name: pytorch
---
# RIFE — Real-Time Intermediate Flow Estimation
Safetensors re-host of the RIFE v4 frame interpolation model from
[ECCV2022-RIFE](https://github.com/hzwer/ECCV2022-RIFE) (MIT license, © Megvii Inc.).
## What is different from the original
| | Original | This repo |
|---|---|---|
| **Weight format** | `.pkl` hosted on Google Drive | `.safetensors` hosted on Hugging Face |
| **TensorRT / `torch.compile`** | Known issues with torchinductor and TensorRT backends | Fixed — model sources are fully compatible |
The architectural code in [interpolation_model.py](interpolation_model.py) is a minimal
clean-up of the upstream
[`model/IFNet.py`](https://github.com/hzwer/ECCV2022-RIFE/blob/main/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
| File | Description |
|------|-------------|
| `flownet.safetensors` | Model weights (converted from original `.pkl`) |
| `interpolation_model.py` | `IFNet` model definition (compile-friendly fork of upstream) |
| `demo.py` | Minimal runnable example |
| `requirements.txt` | Python 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](LICENSE).
Original work © Megvii Inc. This re-host adds no new restrictions.
|