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 .
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.


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
│ ├── ...
└── ...
To train Drone-Guard
on a dataset, run:
python train.py --cfg <config-file> --pseudo True
For 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 data
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.pth
- We use YAML for configuration.
- We provide a couple preset configurations.
- Please refer to
config.py
for documentation on what each configuration does.
If you find our work useful, please consider citing:
Paper submitted
For any question, please file an issue or contact:
Wassim Sliti : wassim.sliti@ept.ucar.tn
The code is built on top of code provided by Le et al. github