Instructions to use litert-community/RIFE-4.25-Lite with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/RIFE-4.25-Lite with LiteRT:
# 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
RIFE-4.25-Lite for LiteRT
FP32 LiteRT/TFLite export of the official Practical-RIFE 4.25 Lite checkpoint for video-frame interpolation. Given two endpoint frames and an interpolation time, it produces one intermediate RGB frame. The export uses the inference network with scale list [32, 16, 8, 4, 1] and no ensemble.
Model file
RIFE-4.25-Lite-fp32.tflite ยท FP32 ยท 23.75 MB. The file hash is in SHA256SUMS.
The TFLite signature is main. All input and output tensors are float32; shapes are fixed. Image/video decoding, preprocessing, and application postprocessing run on the host.
| Direction | Name | Shape | Meaning |
|---|---|---|---|
| Input | frame0 |
[1, 3, 256, 512] |
Earlier RGB frame in [0, 1], NCHW |
| Input | frame1 |
[1, 3, 256, 512] |
Later RGB frame in [0, 1], NCHW |
| Input | timestep |
[1, 1, 1, 1] |
Interpolation fraction in [0, 1] |
| Output | interpolated_frame |
[1, 3, 256, 512] |
Intermediate RGB frame, NCHW |
Preprocessing and outputs
Provide two RGB frames in chronological order, each height 256 ร width 512, rescaled to [0, 1] in NCHW order. Both dimensions satisfy the upstream multiple-of-128 size requirement. The example resizes the complete frames to this fixed resolution. Supply timestep as a float32 tensor of shape [1, 1, 1, 1]: 0 is the first endpoint, 1 is the second, and 0.5 requests the midpoint.
The output is RGB at the same fixed resolution and pixel scale. Convert it to an image or pass it to a host video encoder. Video decoding, frame scheduling, and video encoding are outside the graph.
Run on CPU
pip install ai-edge-litert huggingface_hub numpy opencv-python-headless
import numpy as np
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter
import cv2
def prepare_frame(path):
bgr = cv2.imread(path)
if bgr is None:
raise FileNotFoundError(path)
rgb = cv2.cvtColor(cv2.resize(bgr, (512, 256), interpolation=cv2.INTER_LINEAR),
cv2.COLOR_BGR2RGB)
return np.ascontiguousarray(rgb.transpose(2, 0, 1)[None], dtype=np.float32) / 255.0
frame0 = prepare_frame("frame0.png")
frame1 = prepare_frame("frame1.png")
timestep = np.full((1, 1, 1, 1), 0.5, dtype=np.float32)
model_path = hf_hub_download("litert-community/RIFE-4.25-Lite", "RIFE-4.25-Lite-fp32.tflite")
interpreter = Interpreter(model_path=model_path, num_threads=4)
interpreter.allocate_tensors()
run = interpreter.get_signature_runner("main")
rgb = run(frame0=frame0, frame1=frame1, timestep=timestep)["interpolated_frame"][0]
rgb = np.rint(np.clip(rgb.transpose(1, 2, 0), 0, 1) * 255).astype(np.uint8)
cv2.imwrite("interpolated.png", cv2.cvtColor(rgb, cv2.COLOR_RGB2BGR))
Source and license
The source is Practical-RIFE by Zhewei Huang and collaborators, at revision bbfd2ea90910789a860ea3e2b32a240cd577b75e. The weights come from the official 4.25 Lite archive linked by that revision. The upstream README licenses its linked trained-model downloads under MIT. Checkpoint archive SHA256: e84366c23e0eb1a637a55aad2e4f3442ec2bf4c388043b4aabbf590be289e6e8.
This FP32 conversion uses the original pretrained weights with a fixed-shape TFLite interface. License: MIT.
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}
}
- Downloads last month
- 9