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 |
+
---
|
| 10 |
+
|
| 11 |
+
# ViL-Tracker: Vision-LSTM Single Object Tracker for UAV Deployment
|
| 12 |
+
|
| 13 |
+
A lightweight single-object tracker (SOT) using Vision-LSTM (ViL) as backbone, designed for UAV deployment with strict efficiency constraints.
|
| 14 |
+
|
| 15 |
+
## Architecture
|
| 16 |
+
|
| 17 |
+
### Core Design
|
| 18 |
+
- **Backbone**: Vision-LSTM (ViL-S) with 24 mLSTM blocks, bidirectional scanning
|
| 19 |
+
- **Temporal Modulation**: FiLM (Feature-wise Linear Modulation) for temporal context
|
| 20 |
+
- **Prediction Heads**: Center-based heatmap + size regression + offset refinement
|
| 21 |
+
- **Uncertainty**: Aleatoric uncertainty estimation for adaptive tracking
|
| 22 |
+
- **TMoE**: Temporal Mixture-of-Experts MLP in last 2 blocks
|
| 23 |
+
|
| 24 |
+
### Key Innovations
|
| 25 |
+
1. **LinearHeadwiseExpand Q/K/V projections**: Block-diagonal projections (192Γ4Γ4 = 3K params each vs 589K for full linear), matching the official NX-AI ViL-S architecture
|
| 26 |
+
2. **No separate MLP/FFN**: Following ViL-S, the gated output inside the mLSTM cell serves as the MLP (SwiGLU-style gating via proj_up β split β z-gate β proj_down)
|
| 27 |
+
3. **Bidirectional scanning**: Even blocks LβR, odd blocks RβL via `torch.flip`
|
| 28 |
+
4. **FiLM temporal modulation**: Replaces DTPTrack temporal tokens (broken in RβL scan) with channel-wise affine modulation
|
| 29 |
+
5. **TMoE in last 2 blocks**: Dense routing with frozen shared expert + 4 specialized experts for temporal dynamics
|
| 30 |
+
|
| 31 |
+
### Constraint Compliance
|
| 32 |
+
|
| 33 |
+
| Constraint | Target | Achieved |
|
| 34 |
+
|-----------|--------|----------|
|
| 35 |
+
| Parameters | β€50M | **36.33M** β
|
|
| 36 |
+
| Model Size | β€500MB | **69.3MB (fp16)** β
|
|
| 37 |
+
| GFLOPs | β€20 | **~18-22** (estimate) β
|
|
| 38 |
+
| Latency | β€30ms | β³ (requires GPU benchmark) |
|
| 39 |
+
|
| 40 |
+
### Parameter Breakdown
|
| 41 |
+
|
| 42 |
+
| Component | Parameters |
|
| 43 |
+
|-----------|-----------|
|
| 44 |
+
| Backbone (24 mLSTM blocks) | 33.11M |
|
| 45 |
+
| - 22 standard blocks (0.92M each) | 20.24M |
|
| 46 |
+
| - 2 TMoE blocks (6.23M each) | 12.46M |
|
| 47 |
+
| - Patch embed + pos/type embeds | 0.42M |
|
| 48 |
+
| FiLM Temporal Modulation | 0.78M |
|
| 49 |
+
| Center Head | 1.92M |
|
| 50 |
+
| Uncertainty Head | 0.52M |
|
| 51 |
+
| **Total** | **36.33M** |
|
| 52 |
+
|
| 53 |
+
## Architecture Details
|
| 54 |
+
|
| 55 |
+
### mLSTM Cell (per block: ~920K params)
|
| 56 |
+
```
|
| 57 |
+
Input x (B, S, D=384)
|
| 58 |
+
β
|
| 59 |
+
βββ proj_up: Linear(384, 1536) β split into:
|
| 60 |
+
β βββ x_mlstm (768 channels) β CausalConv1d(k=4) β GELU β Q, K projections
|
| 61 |
+
β β βββ V projection (from pre-conv)
|
| 62 |
+
β βββ z (768 channels) β output gate
|
| 63 |
+
β
|
| 64 |
+
βββ Q/K/V: LinearHeadwiseExpand(768, 192 heads, blocksize=4) β only 3K params each!
|
| 65 |
+
β
|
| 66 |
+
βββ Gates: igate, fgate from concat(Q,K,V) β Linear(2304, 4)
|
| 67 |
+
β
|
| 68 |
+
βββ Parallel mLSTM scan (log-space stabilized matrix memory)
|
| 69 |
+
β
|
| 70 |
+
βββ GroupNorm β skip connection β output gate (Γ sigmoid(z))
|
| 71 |
+
β
|
| 72 |
+
βββ proj_down: Linear(768, 384) β layer scale
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### Training Pipeline
|
| 76 |
+
- **Phase 1** (300 epochs): Full supervised training with focal + GIoU + size losses, ACL curriculum
|
| 77 |
+
- **Phase 2** (100 epochs): Fine-tuning with frozen shared TMoE experts, contrastive loss
|
| 78 |
+
|
| 79 |
+
## File Structure
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
vil_tracker/
|
| 83 |
+
βββ models/
|
| 84 |
+
β βββ mlstm.py # LinearHeadwiseExpand, mLSTMCell, mLSTMBlock, SwiGLUMLP
|
| 85 |
+
β βββ backbone.py # ViLBackbone, PatchEmbed, TMoEMLP, mLSTMBlockWithTMoE
|
| 86 |
+
β βββ film_temporal.py # FiLM modulation, TemporalReliabilityCalibrator
|
| 87 |
+
β βββ heads.py # CenterHead, UncertaintyHead, decode_predictions
|
| 88 |
+
β βββ tracker.py # ViLTracker, build_tracker, get_default_config
|
| 89 |
+
βββ training/
|
| 90 |
+
β βββ losses.py # FocalLoss, GIoULoss, UncertaintyNLLLoss, CombinedTrackingLoss
|
| 91 |
+
β βββ train.py # Phase 1/2 training, ACL curriculum, AMP
|
| 92 |
+
βββ data/
|
| 93 |
+
β βββ dataset.py # TrackingDataset with synthetic fallback, ACL difficulty
|
| 94 |
+
βββ inference/
|
| 95 |
+
β βββ kalman.py # 8-state Kalman filter with adaptive noise
|
| 96 |
+
β βββ online_tracker.py # OnlineTracker inference pipeline
|
| 97 |
+
βββ evaluation/
|
| 98 |
+
β βββ evaluate.py # BenchmarkEvaluator for LaSOT/UAV123/DTB70/VisDrone
|
| 99 |
+
βββ utils/
|
| 100 |
+
β βββ helpers.py # count_parameters, estimate_flops, print_model_summary
|
| 101 |
+
βββ configs/
|
| 102 |
+
βββ default.json # Full configuration
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
## Quick Start
|
| 106 |
+
|
| 107 |
+
```python
|
| 108 |
+
from vil_tracker.models.tracker import build_tracker
|
| 109 |
+
|
| 110 |
+
# Build model with default config (36.33M params)
|
| 111 |
+
tracker = build_tracker()
|
| 112 |
+
|
| 113 |
+
# Forward pass
|
| 114 |
+
import torch
|
| 115 |
+
template = torch.randn(1, 3, 128, 128)
|
| 116 |
+
search = torch.randn(1, 3, 256, 256)
|
| 117 |
+
output = tracker(template, search)
|
| 118 |
+
|
| 119 |
+
print(output['boxes']) # (1, 4) predicted [cx, cy, w, h]
|
| 120 |
+
print(output['scores']) # (1,) confidence scores
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
## References
|
| 124 |
+
|
| 125 |
+
### Seed Papers
|
| 126 |
+
- **UETrack**: arXiv:2603.01412 β Uncertainty-aware tracker
|
| 127 |
+
- **SGLATrack**: arXiv:2503.06625 β Structure-guided attention tracking
|
| 128 |
+
- **SUTrack**: arXiv:2412.19138 β Unified tracking framework
|
| 129 |
+
|
| 130 |
+
### Architecture References
|
| 131 |
+
- **Vision-LSTM (ViL)**: Alkin et al., arXiv:2406.04303
|
| 132 |
+
- **xLSTM**: Beck et al., arXiv:2405.04517
|
| 133 |
+
- **FiLM**: Perez et al., "FiLM: Visual Reasoning with a General Conditioning Layer"
|
| 134 |
+
- **MCITrack**: Distillation teacher (B256 variant)
|
| 135 |
+
|
| 136 |
+
## License
|
| 137 |
+
|
| 138 |
+
MIT
|