Skip to content

rohit1309d/gun-detection

Repository files navigation

Introduction

This repo contains training and evaluation code of CCTV-GUN model. It uses mmdetection to train object detection models.

Requirements

We follow the installation instructions in the mmdetection documentation here. Specifically, our code requires mmcls=0.25.0, mmcv-full=1.7.0 and torch=1.13.0.

The output of conda env export > env.yml can be found in env.yml. It can be used to create a conda virtual environment with

conda env create  -f env.yml
conda activate env_cc
pip install openmim
mim install mmcv-full==1.7.0
pip install -e . 

Data

We use images from three datasets :

  1. Youtube Images
  2. US Real-time Gun detection dataset (USRT)

Instructions on how to download these datasets can be found in dataset_instructions.md .

Training

All of the above datasets consists of two classes : Person (class 0) and Handgun (class 1). To train a detection model on this dataset, run

python tools/train.py --config <path/to/model/config.py> --dataset-config <path/to/dataset/config.py> <extra_args>
  • Model config files link

  • Dataset config files link

  • Trained models link

Extra args

To adjust the training batch size

<base_command> --cfg-options data.samples_per_gpu=<batch-size>

Using weights and biases to log metrics: After you create an account in wandb, change entity and project in train.py to your wandb username and project name. Then

<base_command> --use-wandb --wandb-name <name-of-the-experiment>

Examples:

Train a Swin-T on Ytimgs (Intra-dataset)

python tools/train.py --config configs/gun_detection/swin_transformer.py --dataset-config configs/_base_/datasets/gun_detection/ytimgs.py --cfg-options data.samples_per_gpu=6

Testing

To evaluate a trained model, run

python tools/test.py --config <path/to/model/config.py> --dataset-config <path/to/dataset/config.py> --checkpoint <path/to/trained/model> --work-dir <path/to/save/test/scores> --eval bbox

Examples:

Evaluate a ConvNeXt trained on USRT

python tools/test.py --config configs/gun_detection/convnext.py --dataset-config configs/_base/datasets/gun_detection/usrt.py --checkpoint <path/to/mgd+usrt/trained/model.pth> --work-dir <path/to/save/test/scores> --eval bbox

To save the bounding box predictions on test set , add --save-path <path/to/output/folder> to the above command.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published