S-TSViT: An Energy-Efficient Spiking Transformer for Satellite Image Time Series Analysis

February 26, 2026 ยท View on GitHub

License

Fusion of TSViT (Temporal-Spatial Vision Transformer) and SVF (SpikeVideoFormer)
Spiking Neural Networks meet Remote Sensing for low energy consumption, high-performance crop segmentation.


๐Ÿ“‹ Overview

S-TSViT bridges two research frontiers:

ComponentSourceContribution
TSViTDeepSatModels (Tarasoiu et al., 2023)Temporal-spatial attention for satellite time series
SVFSpikeVideoFormerEnergy-efficient spiking neurons for video/spatio-temporal data

Our Innovation: Replace TSViT's standard temporal encoder with Spiking Neural Network (SNN) dynamics, achieving:

  • โšก 58ร— lower energy consumption in theory (compared to equivalent ANNs)
  • ๐Ÿง  Achieved SOTA in PASTIS dataset (highest with 66.9%)
  • ๐Ÿ”ฝ Reduced model size by 12%.

Paper: PDF version

๐Ÿ—๏ธ Architecture

S-TSViT Architecture

Two Variants

VariantTemporal CollapseUse Case
SpikeTSViTMeanBefore spatial encodingFaster, less memory
SpikeTSViTNoMeanAfter spatial encodingRicher spatio-temporal features

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8+
  • CUDA-capable GPU (10GB+ VRAM recommended)

Quick Start

# Clone repository
git clone https://github.com/hukaiems/Spiking_Temporo-Spatial_Vision_Transformer.git
cd DeepSatModels_SNN

# One-command setup (downloads PASTIS data automatically)
export KAGGLE_USERNAME="your_username"
export KAGGLE_KEY="your_key"
bash setup_pastis.sh

The setup script will:

  • Install dependencies (requirements.txt)
  • Download PASTIS dataset from Kaggle (I have upload it myself)
  • Prepare checkpoint directory

๐Ÿš€ Training

This is my traning script on kaggle using P100.

# 1.51 M 
!python /kaggle/working/DeepSatModels_SNN/train_and_eval/train_stsvit.py \
    --csv_path /kaggle/working/DeepSatModels_SNN/configs/PASTIS24/splits/old_split_kaggle/train_exp1_chunks_123.csv.bak \
    --val_csv_path /kaggle/working/DeepSatModels_SNN/configs/PASTIS24/splits/old_split_kaggle/chunk_4_paths.csv.bak \
    --resume /kaggle/input/spike-tsvit/pytorch/default/54/128dim_pastis_ver3/training/s_tsvit_ignore_128dim_21e_pastis_1.pth \
    --model_type no_mean \
    --att_mode 2D_ham \
    --norm_type gn \
    --loss_type focal \
    --focal_a_weight 2 \
    --max_seq_len 49 \
    --batch_size 2 \
    --grad_accum_steps 8 \
    --temporal_depth 3 \
    --spatial_depth 2 \
    --embed_dim 128 \
    --heads 8 \
    --lr 5e-4 \
    --epochs 24 \
    --checkpoint_path /kaggle/working/s_tsvit_ignore_128dim_24e_pastis_1.pth \
    --no_progress_bar

Key Arguments

ArgumentOptionsDescription
--model_typemean, no_meanTemporal collapse strategy (use the no_mean for the best result)
--att_mode2D_dot, 2D_hamAttention mechanism (ham is better)
--loss_typestandard, weighted, focalLoss function
--norm_typebn, gnBatch vs Group normalization

Resume Training

python train_and_eval/train_stsvit.py \
    --resume checkpoints/spiketsvit_best_latest.pth \
    ... # other args

๐ŸŽฏ Inference & Analysis

My inference script in kaggle.

!python /kaggle/working/DeepSatModels_SNN/train_and_eval/inference_s_tsvit.py \
    --val_csv_path /kaggle/working/DeepSatModels_SNN/configs/PASTIS24/splits/old_split_kaggle/chunk_4_paths.csv.bak \
    --checkpoint_path /kaggle/input/s-tsvit-testing/pytorch/default/12/128dim_pastis_ver3_final/testing/spike_tsvit_151M_pastis_5_best.pth \
    --model_type no_mean \
    --att_mode 2D_ham \
    --norm_type gn \
    --max_seq_len 49 \
    --batch_size 2 \
    --temporal_depth 3 \
    --spatial_depth 2 \
    --embed_dim 128 \
    --heads 8 \
    --inference

Analysis Tools

FlagAnalysis
--inferenceStandard accuracy (mIoU, OA) + top-10 best/worst samples
--test_per_classPer-class accuracy breakdown
--test_energySNN energy consumption (synaptic operations)
--temporal_importanceWhich time steps matter most per class
--NDVIPhenological confusion (crop growth cycles)
--analyze_cloudRobustness to cloud cover
--confusion_matrixFull classification confusion
--visual_comparisonError map visualization
--deploy_inferenceSingle-sample latency test

๐Ÿ“Š Results

PASTIS Dataset (Crop Segmentation)

ModelmIoUEnergy*Params
TSViT (baseline)~0.654100%1.7M
S-TSViT (Ours)~0.669~6%1.5M

*Energy estimated via synaptic operations (SynOps)

Key Insight: S-TSViT achieves comparable accuracy with ~58ร— energy reduction, critical for edge deployment on satellites or IoT devices.


๐Ÿงช Reproducibility

Datasets

DatasetClassesBandsResolutionSource
PASTIS20 (19 crops + bg)10 (S2)10mGitHub
France2113 (S2)10mCustom split

Pre-trained Weights

ModelCheckpoint
S-TSViT-NoMeanDownload

๐Ÿ›๏ธ Citation

If you use this code, please cite: Acutally i havent published it anywhere so you can't cite me =))). But you can site other paper that i used to create this.


@inproceedings{tarasoiu2023tsvit,
  title={DeepSatModels: Temporal-Spatial Vision Transformers for Satellite Image Time Series},
  author={Tarasoiu, Michail and others},
  booktitle={ICLR},
  year={2023}
}

@article{zhu2022spikevideoformer,
  title={SpikeVideoFormer: Spiking Neural Networks for Video Understanding},
  author={Zhu, Zhenyu and others},
  journal={arXiv preprint},
  year={2022}
}

๐Ÿ“‚ Repository Structure

S-TSViT/
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ snn/
โ”‚       โ”œโ”€โ”€ spike_tsvit.py          # Main architectures
โ”‚       โ”œโ”€โ”€ snn_transformer.py      # MS_Block, attention layers
โ”‚       โ”œโ”€โ”€ loss_function.py        # Focal loss
โ”‚       โ””โ”€โ”€ helper_functions.py     # Analysis tools
โ”œโ”€โ”€ train_and_eval/
โ”‚   โ”œโ”€โ”€ train_stsvit.py             # Training script
โ”‚   โ””โ”€โ”€ inference_s_tsvit.py        # Evaluation & analysis
โ”œโ”€โ”€ spike_data/
โ”‚   โ”œโ”€โ”€ pastis_dataset.py           # PASTIS dataloader
โ”‚   โ””โ”€โ”€ france_dataset.py           # France dataloader
โ”œโ”€โ”€ setup_pastis.sh                 # One-command setup
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ LICENSE.txt

๐Ÿค Acknowledgments


๐Ÿ“ง Contact

For questions or collaborations: Gmail


License: Apache 2.0 โ€” see LICENSE.txt