Lucas Jackson commited on
Commit
bb5183f
·
verified ·
1 Parent(s): d452ef5

Update from github.com/lucasjacks0n/LeanScene@f3f307c

Browse files
Files changed (6) hide show
  1. LICENSE +21 -0
  2. README.md +98 -0
  3. leanscene.pt +3 -0
  4. onnx/features.onnx +3 -0
  5. onnx/head.onnx +3 -0
  6. onnx/meta.json +11 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lucas Jackson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,3 +1,101 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ pipeline_tag: video-classification
4
+ tags:
5
+ - shot-boundary-detection
6
+ - shot-transition-detection
7
+ - scene-detection
8
+ - video
9
+ - onnx
10
+ - pytorch
11
  ---
12
+
13
+ # LeanScene
14
+
15
+ A 0.39M-parameter network that finds shot transitions (cuts, dissolves, fades) in video.
16
+ It scores higher than TransNet V2 on all three of that model's benchmarks, with 115x fewer
17
+ operations per frame.
18
+
19
+ - **Try it in your browser:** <https://lucasjackson.dev/leanscene/>. Drop a video and see every
20
+ transition on a timeline. It runs in the tab; nothing is uploaded.
21
+ - **Code, training and evaluation:** <https://github.com/lucasjacks0n/LeanScene>
22
+
23
+ ## Results
24
+
25
+ | | BBC Planet Earth | ClipShots | RAI | Parameters | MACs per frame |
26
+ |---|---|---|---|---|---|
27
+ | TransNet V2 | 96.1 | 77.7 | 92.6 | 7.62 M | 832 M |
28
+ | **LeanScene** (mean of 5 seeds) | **97.4** ± 0.1 | **79.1** ± 0.2 | **93.7** ± 0.5 | **0.39 M** | **7.2 M** |
29
+ | The weights in this repository (one of the 5 seeds) | 97.45 | 78.82 | 93.03 | | |
30
+
31
+ F1 over transitions with TransNet V2's own protocol (two-frame tolerance). Both models are run
32
+ through the same decoding and scoring code, and LeanScene's decision rule was fixed before the
33
+ test sets were scored. The GitHub README has the fine print.
34
+
35
+ ## Use it
36
+
37
+ The weights ship inside the packages, so the usual way to use the model is to install one of
38
+ them; nothing is downloaded at run time.
39
+
40
+ ```sh
41
+ # Python
42
+ pip install git+https://github.com/lucasjacks0n/LeanScene
43
+ leanscene video.mp4
44
+
45
+ # Node.js
46
+ npm install leanscene
47
+ npx leanscene video.mp4
48
+ ```
49
+
50
+ ```python
51
+ import leanscene
52
+
53
+ result = leanscene.detect("video.mp4")
54
+ result.shots # [(0, 343), (344, 2403), ...] inclusive frame ranges, 0-based
55
+ result.transitions # [Transition(start=344, end=344, kind='cut'), ...]
56
+ result.probs # (frames, 3) float32: same, cut, fade
57
+ ```
58
+
59
+ ```ts
60
+ import { detect } from "leanscene";
61
+ const { shots, transitions } = await detect("video.mp4");
62
+ ```
63
+
64
+ A cut is reported on the first frame of the new shot. A gradual transition is the run of
65
+ frames inside it, and those frames belong to neither neighbouring shot.
66
+
67
+ ## Files
68
+
69
+ | File | What it is |
70
+ |---|---|
71
+ | `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` |
72
+ | `onnx/features.onnx` | The per-frame network as ONNX: 100x100 frames in, features out |
73
+ | `onnx/head.onnx` | The temporal head as ONNX: features in, per-frame probabilities (same, cut, fade) out |
74
+ | `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) |
75
+
76
+ The two ONNX graphs are the ones the Node.js package and the browser demo run. The colour
77
+ histogram that sits between them is computed outside the graphs; the Node.js package's source
78
+ shows how the pieces fit together.
79
+
80
+ ## Training data
81
+
82
+ A mix of synthetic transitions made from single-shot clips, hand-labeled YouTube videos, and
83
+ ClipShots. The single-shot clips are not distributed, so these exact weights cannot be
84
+ retrained; the training code and the labels are in the GitHub repository.
85
+
86
+ ## Limits
87
+
88
+ - The Python package decodes with OpenCV. Times are frame index divided by the container's
89
+ frame rate, so they drift on variable-frame-rate files; frame indices are exact.
90
+ - Scores are for the three benchmarks above. Other kinds of footage were not measured.
91
+
92
+ ## Citation
93
+
94
+ The paper is in preparation. Until then:
95
+
96
+ ```
97
+ Lucas Jackson. LeanScene: A 0.39M-Parameter Network for Fast Shot Transition Detection.
98
+ https://github.com/lucasjacks0n/LeanScene
99
+ ```
100
+
101
+ MIT license.
leanscene.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0d1cc2a77f8aa91d0e27868734bd8da621cd62dbaf701fb6979558ee03f4730
3
+ size 1603123
onnx/features.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4718ff9f153f9c377d25ca27846da4bdd6a6a0b0e84fd9a58a1ed4fc822cee5
3
+ size 279293
onnx/head.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a064baae28e72c4f8a8eb5e0dfc8449ffeb8ef1dad2968bca4edb72b723b9b41
3
+ size 1308625
onnx/meta.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checkpoint": "leanscene",
3
+ "dim": 896,
4
+ "feat": 128,
5
+ "size": 100,
6
+ "histBins": 4,
7
+ "receptiveField": 63,
8
+ "cut": 0.7,
9
+ "fade": 0.8,
10
+ "close": 8
11
+ }