Versalit SNN-Forecast
A spiking neural network that only sees past events and draws where the object will be — with almost three times less error than straight-line extrapolation.
What it does
Show the network the events of a moving ball over the last 32 frames, and it draws where the ball will be 4, 8, 12, 16 and 20 frames later — including the curve of the fall and the bounce on the ground.
The network gets no position and no velocity. Only events.
How it works
The 32 frames of history become 8 event frames, and each one is fed to the network for 2 timesteps. Three convolutions and a dense layer, all with LIF neurons, keep the motion dynamics in the membrane potential itself — no huge window, no RNN. The output accumulates potential and becomes the 5 future positions.
Training is 100% synthetic: a simulator generates ballistic trajectories with gravity, bounces and wall reflections, a new one for every example.
simulator → frames → ON/OFF events (DVS) 32 frames of history = 8 event frames × 2 timesteps → 3 convolutions + LIF → dense (128) + LIF → output accumulates potential → position at +4, +8, +12, +16, +20
Metrics on unseen trajectories
| Horizon | SNN (events only) | Straight line* | Standing still* |
|---|---|---|---|
| +4 frames | 6.5 | 6.2 | 8.4 |
| +8 | 7.7 | 13.8 | 13.5 |
| +12 | 7.7 | 21.8 | 17.5 |
| +16 | 8.0 | 29.6 | 20.5 |
| +20 | 8.4 | 37.0 | 22.8 |
| Mean | 7.7 | 21.7 | 16.5 |
How to read it: error in pixels on a 64×64 grid, measured on 1,000 new trajectories. Both baselines (*) get the object's true position — information the SNN does not have. Even so, from +8 frames on the SNN is far more accurate: it learned gravity and the bounce; a straight line does not know the ball is going to fall.
What about real video?
The repository includes a second, much smaller model (10,762 parameters) that reads car trajectories extracted by a tracker and predicts a correction on top of straight-line extrapolation. On real traffic, the correction only helped at the longest horizon: at +20 frames the error dropped from 80 to 44 pixels, but from +4 to +16 frames the plain straight line was better.
That is why it stays in the repository as an experiment, with the full numbers in the model card — not as a result.
How to run it
git clone https://huggingface.co/delvek/versalit-snn-forecast cd versalit-snn-forecast pip install -r requirements.txt python -m src.demo -o forecast.mp4 # synthetic demo python -m src.train --epochs 30 # on-the-fly trajectories
Real video (experimental)
python -m src.extract_trajs video1.mp4 video2.mp4
python -m src.train_real --epochs 40
python eval_real.py video.mp4 # vs. linear extrapolation
Honest limitations
- The strong result is synthetic: one object, clean background, simple physics, a 64×64 grid.
- On real video, the SNN only beats the straight line at +20 frames.
- The event camera is simulated from regular video.