sniklaus/softmax-splatting
an implementation of softmax splatting for differentiable forward warping using PyTorch
What it solves
Video frame interpolation creates intermediate frames between two existing images, which is useful for slow-motion effects or smoothing video. A core challenge is correctly moving pixels from one frame to another when multiple source pixels map to the same target location. This project implements a technique called softmax splatting, which decides how to combine those overlapping contributions in a principled and differentiable way.
How it works
Softmax splatting is a method for forward warping, where each pixel from an input image is moved along an optical flow vector to a new position in the output frame. When several pixels land on the same spot, they must be blended. Instead of simple summation or averaging, softmax splatting uses an importance metric (like a per-pixel confidence score) weighted by a softmax operation. This makes the blending translational invariant, meaning it behaves consistently even when the scene moves. The implementation is written in CUDA and uses CuPy for GPU acceleration, and it integrates with PyTorch as a custom layer.
To use it, you provide two frames plus their optical flow (and optionally a metric), and the layer returns the warped result. The README includes command-line scripts for running on a single pair of frames or on a video, and a small demo script that compares softmax splatting against summation, average, and linear splatting.
Who it’s for
Researchers and developers working on video frame interpolation, optical flow-based warping, or any task that requires differentiable forward warping. It is particularly useful for those who want to reproduce the results from the referenced CVPR 2020 paper or build on top of this operator in their own PyTorch projects.
Highlights
- Implements a differentiable forward-warping operator that handles multiple source-to-target pixel collisions gracefully.
- Uses a translational invariant importance metric (softmax) to avoid the pitfalls of simple blending.
- Includes ready-to-run scripts for single image pairs, videos, and benchmark evaluations (Middlebury and Xiph).
- Written in CUDA with CuPy for fast GPU execution, and designed as a drop-in PyTorch layer.
- The project is strictly for academic use; commercial licensing is available on request.
Related
- Project
- Project
- Project
- Project