slitiWassim/Drone-Guard
A Self-Supervised Deep Learning Framework for Spatiotemporal Anomaly Detection in UAV Surveillance Videos
Drone-Guard: A Self-Supervised Deep Learning Framework for Spatiotemporal Anomaly Detection in UAV Surveillance Videos
This is the code for Drone-Guard: A Self-Supervised Deep Learning Framework for Spatiotemporal Anomaly Detection in UAV Surveillance Videos .
Project | Video | Paper
Related Works
ANDT: See ANDT : Anomaly detection in aerial videos with transformers .
HSTforU: See HSTforU: Anomaly Detection in Aerial and Ground-based Videos with Hierarchical Spatio-Temporal Transformer for U-net.
FastAno: See FastAno: Fast Anomaly Detection via Spatio-temporal Patch Transformation.
Model
Setup
The code can be run under any environment with Python 3.12 and above.
(It may run with lower versions, but we have not tested it).
Install the required packages:
pip install -r requirements.txt
Clone this repo:
git clone https://github.com/slitiWassim/Drone-Guard.git
cd Drone-Guard/
We evaluate Drone-Guard on:
| Dataset | Link |
|---|---|
| UCSD Ped2 | |
| CUHK Avenue | |
| ShanghaiTech | |
| Drone-Anomaly |
A dataset is a directory with the following structure:
$ tree data
ped2/avenue
├── training
│ └── frames
│ ├── ${video_1}$
│ │ ├── 000.jpg
│ │ ├── 001.jpg
│ │ └── ...
│ ├── ${video_2}$
│ │ ├── 00.jpg
│ │ └── ...
│ └── ...
└── testing
└── frames
├── ${video_1}$
│ ├── 000.jpg
│ ├── 001.jpg
│ └── ...
├── ${video_2}$
│ ├── 000.jpg
│ └── ...
└── ...
shanghaitech
├── training
│ └── frames
│ ├── ${video_1}$
│ │ ├── 000.jpg
│ │ ├── 001.jpg
│ │ └── ...
│ ├── ${video_2}$
│ │ ├── 00.jpg
│ │ └── ...
│ └── ...
└── testing
└── frames
├── ${video_1}$
│ ├── 000.jpg
│ ├── 001.jpg
│ └── ...
├── ${video_2}$
│ ├── 000.jpg
│ └── ...
└── ...
drone
├──bike
│ ├──training
│ │ └── frames
│ │ ├── ${video_1}$
│ │ │ ├── 0.jpg
│ │ │ ├── 1.jpg
│ │ │ └── ...
│ │ ├── ${video_2}$
│ │ │ ├── 00.jpg
│ │ │ └── ...
│ │ └── ...
│ ├── testing
│ │ └── frames
│ │ ├── ${video_1}$
│ │ │ ├── 000.jpg
│ │ │ ├── 001.jpg
│ │ │ └── ...
│ │ ├── ${video_2}$
│ │ │ ├── 000.jpg
│ │ │ └── ...
│ │ └── ...
│ └── annotation
│ ├── 01.npy
│ ├── 02.npy
│ └── ...
├── highway
│ ├── ...
└── ...
Training
To train Drone-Guard on a dataset, run:
python train.py --cfg <config-file> --pseudo TrueFor example, to train Drone-Guard on Ped2:
python train.py \
--cfg config/ped2.yaml \
--pseudo True # To Train model with both normal and pseudo anomalies dataEvaluation
Please first download the pre-trained model
| Dataset | Pretrained Model |
|---|---|
| UCSD Ped2 | |
| CUHK Avenue | |
| ShanghaiTech | |
| Drone-Anomaly |
To evaluate a pretrained Drone-Guard on a dataset, run:
python test.py \
--cfg <path/to/config/file> \
--pretrained </path/to/pre-trained/model> For example, to evaluate Drone-Guard on Ped2:
python test.py \
--cfg config/ped2.yaml \
--model-file pre-trained/best_model_ped2.pthConfiguration
- We use YAML for configuration.
- We provide a couple preset configurations.
- Please refer to
config.pyfor documentation on what each configuration does.
Citing
If you find our work useful, please consider citing:
@article{sliti2025drone,
title={Drone-guard: A self-supervised deep learning framework for real-time spatiotemporal anomaly detection in UAV surveillance systems},
author={Sliti, Wassim and Besbes, Olfa},
journal={Neurocomputing},
pages={131168},
year={2025},
publisher={Elsevier}
}
Contact
For any question, please file an issue or contact:
Wassim Sliti : wassim.sliti@ept.ucar.tn
Acknowledgement
The code is built on top of code provided by Le et al. github