Giter VIP home page Giter VIP logo

simple-accident-prediction's Introduction

simple-accident-prediction

Overview

This is an implementation of a very simple accident prediction model that uses Gated Recurrent Unit (GRU) to predict an accident. The architecture of the model is developed with PyTorch. The input video frames are passed trough a CNN feature extractor (eg. ResNet50/VGG16), then the spatio-temporal relations of the extracted features are learnt using the GRU to predict the accident probablity of each video frame. The architecture is as below:

Architecture

Dataset

This code supports Street Accident (SA) Dataset (also known as DAD dataset). The video dataset needs to be converted into frames to train and test the network.

  • Please download the frames from here. Note that, downloaded datasets needs to be put inside the folder data/
  • (Optional) Original video can be downloaded from the SA official.

Requirement

  • Pytorch >=1.2
  • torchvision >= 0.4
  • tqdm
  • tensorboardX
  • numpy
  • natsort
  • opencv-python >= 4.1.1.26
  • Pillow

Getting started

  • Install the required dependencies
  • Clone this repository by typing:
git clone https://github.com/monjurulkarim/simple-accident-prediction
  • Download the dataset and put it inside data

Training

To train the network on you terminal type:

python train.py

Testing

  • This repository also integrated grad-cam tool to generate class acitavation maps. Grad-cam needs to be installed first to use this module.
pip install grad-cam==1.3.1

To visualize the grad-cam result:

python demo.py

(To see the prediction score, one block of code needs to be uncommented first. Instruction can be found inside the code)

Acknowledgement

  1. PyTorch library for CAM methods. https://github.com/jacobgil/pytorch-grad-cam

simple-accident-prediction's People

Contributors

monjurulkarim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.