Python package for learning-based SSTM optical flow inference
Project description
SSTM-PyPI
Package Description
SSTM-PyPI is a python package for dense optical flow estimation from image sequences based on our deep-learning method, SSTM: Spatiotemporal recurrent transformers for multi-frame optical flow estimation.
It supports both two-frame and three-frame inference.
For a two-frame input, the package predicts a single flow field:
f12: optical flow from frame 1 → frame 2
For a three-frame input, the package predicts two flow fields:
f12: optical flow from frame 1 → frame 2f23: optical flow from frame 2 → frame 3
The package also supports:
- input image paths
- already loaded OpenCV / NumPy images
- optional saving of flow fields as
.flo - optional color-wheel visualization of predicted flow
Installation
conda create -n sstm_env python=3.10
conda activate sstm_env
pip install torch torchvision
pip install sstm-flow
Usage
Two-frame optical flow
from sstm import estimate_flow
flow = estimate_flow(
"checkpoints/ft-sintel.pth",
"frame_0013.png",
"frame_0014.png"
)
Three-frame optical flow
from sstm import estimate_flow
f12, f23 = estimate_flow(
"checkpoints/ft-sintel.pth",
"frame_0013.png",
"frame_0014.png",
"frame_0015.png"
)
Using already loaded images
The API also supports images already loaded with OpenCV or NumPy.
import cv2
from sstm import estimate_flow
img1 = cv2.imread("frame_0013.png")
img2 = cv2.imread("frame_0014.png")
flow = estimate_flow(
"checkpoints/ft-sintel.pth",
img1,
img2
)
Faster inference (recommended)
If running inference on multiple frame pairs, load the model once.
import cv2
from sstm import load_model, infer_flow_pair
model = load_model("checkpoints/ft-sintel.pth")
img1 = cv2.imread("frame_0013.png")
img2 = cv2.imread("frame_0014.png")
flow = infer_flow_pair(model, img1, img2)
Saving flow outputs using .flo and standard flow color-wheel visualization
from sstm import estimate_flow
estimate_flow(
"checkpoints/ft-sintel.pth",
"frame_0013.png",
"frame_0014.png",
output_dir="results",
save_flo=True,
save_vis_outputs=True
)
This will output:
results/
├── flow0001.flo
├── flow0001.png
Model weight description and task specific recommendation
Under checkpoints/. there are three different fine-tuned versions of SSTM
| Model | Description | Recommended Use |
|---|---|---|
| ft-speckle-sintel | Fine-tuned for motion patterns that exhibit local spatial deformation. | Biomechanics, elastography, biological tissue motion, speckle tracking |
| ft-sintel | General-purpose optical flow model trained on non-rigid motion with diverse dynamics. | Natural scenes, animation, and general research applications |
| ft-kitti | Fine-tuned for rigid scene motion typical in driving environments. | Autonomous driving, vehicle motion, rigid object tracking |
Citation
If you find this work useful please cite:
@article{ferede2023sstm,
title={SSTM: Spatiotemporal recurrent transformers for multi-frame optical flow estimation},
author={Ferede, Fisseha Admasu and Balasubramanian, Madhusudhanan},
journal={Neurocomputing},
volume={558},
pages={126705},
year={2023},
publisher={Elsevier}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sstm_flow-0.1.4.tar.gz.
File metadata
- Download URL: sstm_flow-0.1.4.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c1ce99efb6a069f1145d6599cd7cbe6e73e6c162a217712e0b84ec2a672f651
|
|
| MD5 |
90b28cfed39adac83ec482891e3e74b1
|
|
| BLAKE2b-256 |
a7426ed23841945fb0ad2ccab387c9bd751195d1c1e2904d1443fe383e475992
|
File details
Details for the file sstm_flow-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sstm_flow-0.1.4-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f28a134264453a2c3fdccd4f5b83578cd0b8b7af1729d270561212949f444212
|
|
| MD5 |
cf7065b91a30bc2a18073f7e5cfcab39
|
|
| BLAKE2b-256 |
dd909ab40f5e856007eb211e2a06b66b9591018f94abce832e2df772b4d89de9
|