Git Product home page Git Product logo

karim-ahm / realtime-vehicle-detection Goto Github PK

View Code? Open in Web Editor NEW
29.0 5.0 12.0 746 KB

Graduation project repository, Real-time vehicle detection using two different approaches. HOG+SVM traditional approach and Deep Learning based approach using state of the art YOLO convolutional neural network.

Makefile 0.25% Python 1.58% Shell 0.23% Cuda 7.86% C 89.77% C++ 0.31%
deep-learning yolo vehicle-detection autonomous-car adas embedded-vision realtime

realtime-vehicle-detection's Introduction

Realtime vehicle detection driver assistance system

Realtime vehicle detection for driver assistance using two approaches:

  1. Traditional feature engineering approach: using Histogram of Oriented Gradients + Support vector machines. This approach proved to be very slow at the image level so we discontinued it in favor of the deep learning based approach.

  2. Deep learning based approach: Using state of the art convolutional neural networks architecture YOLO (You Only Look Once). The system was implemented using the reference framework darknet mimicing the Tiny YOLOv2 by the original authors of the paper .

Environment:

The system was developed using the following:

  1. Hardware:
  • A PC running Ubuntu 16.04 LTS, Intel core i-5 4670-K, Nvidia GTX960, 8 GB RAM. We later ported it on a Nvidia Jetson TK1 to test its performance on a relatively modest embedded system.
  1. Software:
  • For various scripts, we needed Python 2 so we used Anaconda2.
  • Opencv 3.1.
  • CUDA 8.
  • cuDNN 5.1.

Project Goals:

  • Our aim was to create a realtime vehicle detection systems that would detect the surrounding vehicles from the drivers using an incoming video stream only.

Project Information:

  • We used a CNN based approach using YOLO. An extremely fast object detection and classification network. The framework we've used (darknet) is readily implemented in C and CUDA so it provided the maximum possible support for embedded systems with a GPU (Hence, the Jetson TK1 choice).
  • Installing darknet is easy and simple. Training it wasn't. However, the internet is thankfully full of resources for that. We recommend this repository.
  • The network was trained using our custom CFG file and darknet pretrained vanilla weights. We used the Udacity dataset publicly available here. We've written our own scripts to convert the annotations to suit darknet. They're in the scripts folder along with other several useful scripts.

Training steps:

  1. Clone the repository, install the dependencies and build using make after navigating to the repository root folder.
  2. Download and extract the udacity dataset into a folder, then divide the dataset according to your liking (we used 10,000 for training, 3,000 for validation, & another unlabeled dataset for testing).
  3. Run the necessary scripts to generate the files and annotations needed for training.
  4. Run the anchors script to generate the anchors needed for your CFG file.
run both scripts in root darknet folder 
generate anchors: 
gen_anchors.py -filelist path-to-training-file-list -output_dir generated_anchors -num_clusters 5
visualize anchors: 
python visualize_anchors.py -anchor_dir generated_anchors/

Anchors visualization

  1. Create your CFG and data files as mentioned in the repository referenced here.
  2. Start training!

Results:

  • We've obtained an IOU value of 61% at iteration 5,000. The recall rate peak was at 71%. On a GTX960 the network ran at 40FPS and on the Jetson TK1 it ran at 8FPS after various optimizations we've done to both the code and the board itself. to put things into perspective, the GTX960 has 1024 CUDA cores while the Jetson TK1 has 192 CUDA cores only.

Reproducing Results:

  • We were training for only 1 class, Car. We've trained for 8,000 iterations and found out that the best IOU result was obtained at iteration 5,000. You can download our weights file here.
  • The config file of our network is readily present in the cfg folder, as well as the data and names files. However, you'll need to modify the training, validation and names paths in your data file to match those on your environment.
  • Once you're done training (or if you're using our weights file) you can simply invoke one of the following three commands to validate or test YOLO:
./darknet detector valid data/rtcd.data cfg/rtcd.cfg path-to-weights -thresh 0.4
./darknet detector test data/rtcd.data cfg/rtcd.cfg path-to-weights path-to-image -thresh 0.4
./darknet detector demo data/rtcd.data cfg/rtcd.cfg path-to-weights path-to-video -thresh 0.4

Citations:

  1. You Only Look Once: Unified, Real-Time Object Detection.
  2. YOLO9000: Better, Faster, Stronger.
  3. Darknet: Opensource neural networks framework.
  4. AlexeyAB's Darknet repository.
  5. Jumabek's scripts that we modified for the anchors.

realtime-vehicle-detection's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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