A 0.39M-parameter network that finds shot transitions (cuts, dissolves, fades) in video. It scores higher than TransNet V2 on all three of that model's benchmarks, with 115x fewer operations per frame.
| BBC Planet Earth | ClipShots | RAI | Parameters | MACs per frame | |
|---|---|---|---|---|---|
| TransNet V2 | 96.1 | 77.7 | 92.6 | 7.62 M | 832 M |
| LeanScene (mean of 5 seeds) | 97.4 ± 0.1 | 79.1 ± 0.2 | 93.7 ± 0.5 | 0.39 M | 7.2 M |
| The weights in this repository (one of the 5 seeds) | 97.45 | 78.82 | 93.03 |
F1 over transitions with TransNet V2's own protocol (two-frame tolerance). Both models are run through the same decoding and scoring code, and LeanScene's decision rule was fixed before the test sets were scored. The GitHub README has the fine print.
The weights ship inside the packages, so the usual way to use the model is to install one of them; nothing is downloaded at run time.
# Python
pip install leanscene
leanscene video.mp4
# Node.js
npm install leanscene
npx leanscene video.mp4
import leanscene
result = leanscene.detect("video.mp4")
result.shots # [(0, 343), (344, 2403), ...] inclusive frame ranges, 0-based
result.transitions # [Transition(start=344, end=344, kind='cut'), ...]
result.probs # (frames, 3) float32: same, cut, fade
import { detect } from "leanscene";
const { shots, transitions } = await detect("video.mp4");
A cut is reported on the first frame of the new shot. A gradual transition is the run of frames inside it, and those frames belong to neither neighbouring shot.
| File | What it is |
|---|---|
leanscene.pt |
The PyTorch checkpoint the Python package bundles (1.6 MB). Load it with leanscene.load_model("leanscene.pt") or leanscene --model leanscene.pt |
onnx/features.onnx |
The per-frame network as ONNX: 100x100 frames in, features out |
onnx/head.onnx |
The temporal head as ONNX: features in, per-frame probabilities (same, cut, fade) out |
onnx/meta.json |
What the two graphs need around them: input size, feature width, histogram bins, and the decision rule (cut >= 0.7, fade >= 0.8, fade runs closed over gaps of <= 8 frames) |
The two ONNX graphs are the ones the Node.js package and the browser demo run. The colour histogram that sits between them is computed outside the graphs; the Node.js package's source shows how the pieces fit together.
A mix of synthetic transitions made from single-shot clips, hand-labeled YouTube videos, and ClipShots. The single-shot clips are not distributed, so these exact weights cannot be retrained; the training code and the labels are in the GitHub repository.
The paper is in preparation. Until then:
Lucas Jackson. LeanScene: A 0.39M-Parameter Network for Fast Shot Transition Detection.
https://github.com/lucasjacks0n/LeanScene
MIT license.
leanscene.pt 2 MBonnx/head.onnx 1 MBonnx/features.onnx 279.3 kB