Skip to content

slitiWassim/Drone-Guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 .

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 Google drive
CUHK Avenue Google drive
ShanghaiTech Google drive
Drone-Anomaly Google drive

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

Evaluation

Please first download the pre-trained model

Dataset Pretrained Model
UCSD Ped2 Google drive
CUHK Avenue Google drive
ShanghaiTech Google drive
Drone-Anomaly Google drive

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

Configuration

  • We use YAML for configuration.
  • We provide a couple preset configurations.
  • Please refer to config.py for documentation on what each configuration does.

Citing

If you find our work useful, please consider citing:

Paper submitted 

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