GithubHelp home page GithubHelp logo

achen353 / taiwanese-traffic-object-detection Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 3.0 638.53 MB

Training and fine-tuning YOLOv4 Tiny on custom object detection dataset for Taiwanese traffic

License: Other

CMake 1.35% Makefile 0.27% PowerShell 0.42% Shell 0.56% C# 0.14% Batchfile 0.58% Python 4.49% C 64.46% C++ 12.84% Cuda 14.90%
object-detection yolov4 yolov4-darknet yolov4-tiny yolov4-training traffic-object-detection

taiwanese-traffic-object-detection's Introduction

Object Detection on Taiwanese Traffic using YOLOv4 Tiny

Exploration of YOLOv4 Tiny on custom Taiwanese traffic dataset
Trained and tested AlexeyAB's Darknet YOLOv4 Tiny on Nvidia Tesla P100 GPU


Table of Contents

About

In this project, we trained and fine-tuned the YOLOv4 Tiny model on a custom dataset of Taiwanese traffic provided by the Embedded Deep Learning Object Detection Model Compression Competition for Traffic in Asian Countries as training data.

Released in April 2020 by AlexeyAB and his team, respectively, YOLOv4 became one of the fastest object recognition system on the market. It was even deployed as real-time object detection systems as a solution to traffic flow problems in Taiwanese cities such as Taoyuan City and in Hsinchu City.

The project explores the capability of YOLOv4 Tiny, the lightweight version of YOLOv4 developed by the same research team. Moreover, as there has been little publicly available object detection datasets on Taiwanese and Asian traffic (where large numbers of scooters and bicycles are present compared to most Western countries), we took the chance to utilize the dataset provided by Embedded Deep Learning Object Detection Model Compression Competition for Traffic in Asian Countries.

We achieved an 87.2% [email protected] at about 18-23 average FPS with Nvidia Tesla P100 GPU.

DISCLAIMER: This project is an application, not an implementation/modification, of YOLOv4 Tiny. Most of the code is from the original YOLOv4 repository.

Framework and Model

Both YOLOv4 and YOLOv4 Tiny are implemented by AlexeyAB and his team, based on the forked repository from Joseph Redmon's original work on YOLOv1, YOLOv2, and YOLOv3. While there are many implementations of the models in other frameworks such as Tensorflow and PyTorch, we decided to familiarize ourselves with the original Darknet framework.

Visit the original Darknet repo to learn more about the models themselves as well as implementations in other frameworks.

Dataset

The dataset consists of 89002 images of size 1920*1080. There are 4 annotated classes: vehicle, scooter, pedestrian, bicycle. All the images are provided with annotations as training data for the participants of the Embedded Deep Learning Object Detection Model Compression Competition for Traffic in Asian Countries. We used 80% of it as training data and 20% as validation (and test) data.

Mandated by the host of the competition, the data is kept confidential. However, we do provide the weights trained and demonstrations of the model's performance as provided below.

Results

Setting the model resolution 1280*704, we were able to achieve an 87.2% [email protected] at 18-23 FPS on average.


On the validation data:

detections_count = 435135, unique_truth_count = 147062
class_id = 0, name = vehicle, ap = 91.48%        (TP = 86140, FP = 8549)
class_id = 1, name = scooter, ap = 88.69%        (TP = 25877, FP = 2760)
class_id = 2, name = pedestrian, ap = 84.81%     (TP = 11759, FP = 1900)
class_id = 3, name = bicycle, ap = 83.77%        (TP = 1542, FP = 241)

for conf_thresh = 0.25, precision = 0.90, recall = 0.85, F1-score = 0.88
for conf_thresh = 0.25, TP = 125318, FP = 13450, FN = 21744, average IoU = 76.20 %

Below are examples of our model making inferences:

Sunny Day (Avg FPS: 23.0) Clear Night (Avg FPS: 19.7)
Rainy Day (Avg FPS: 20.2) Rainy Night (Avg FPS: 20.3)

Check out predictions folders if the .gif above are loading slow.

Setup

  1. Download archive file, unzip it, and put all the files in the root directory.
  2. Open your terminal, cd into where you'd like to clone this project, and clone the project:
$ git clone https://github.com/achen353/Taiwan-Traffic-Object-Detection.git
  1. Follow the steps in this article. It has very detailed instructions of setting up the environment for training YOLO models.

Note: Make sure your CUDA, cuDNN, CUDA driver and your hardware are compatible. Check compatibility here.

It is highly suggested that you run YOLO with a GPU. If you don't have a GPU, you can use the following free resources Google provides:

If you're training on a remote server via SSH session, this article will help you in keeping the terminal session alive even if you disconnect the SSH session.

How to Run

To train your own model on a custom dataset

The original repository has very detailed steps for training on a custom dataset

To inference using the pre-trained model provided by this project

  1. Get any .avi/.mp4 video file (preferably not more than 1920*1080 to avoid bottlenecks in CPU performance) and place them in where you prefer (we had sample_videos folder for this).
  2. Run make if you haven't and run (assume the file name is test.mp4):
$ ./darknet detector demo data/obj.data cfg/yolov4-tiny-obj.cfg yolov4-tiny-obj_best.weights sample_videos/test.mp4 -out_filename predictions/test.mp4

We have prediction folder made to keep the prediction outputs. If you don't want the video to pop up as the model makes inferences, add -dont_show flag in your command.

Credits

taiwanese-traffic-object-detection's People

Contributors

achen353 avatar acxz avatar adujardin avatar alexeyab avatar aughey avatar avensun avatar bouncyphoton avatar cenit avatar cyyever avatar davidssmith avatar duohappy avatar enesozi avatar giordano avatar ilyaovodov avatar imaami avatar jaledmc avatar jaltmayerpizzorno avatar judwhite avatar jveitchmichaelis avatar marvinklemp avatar mmaaz60 avatar muhammad-maaz-confiz avatar oldgalileo avatar pjreddie avatar tiagoshibata avatar tigerhawkvok avatar tinohager avatar tomheaven avatar vinjn avatar willbattel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

taiwanese-traffic-object-detection's Issues

Fine-tuned models

The result looks like cool. I'm pretty wonder if yolov4-tiny can produce such a good detection accuracy even after fine-tuned with a custom dataset. It would be cool if you would upload your fine-tuned YoloV4-tiny model.

Dataset

Excuse me!

Could you provide the link of the dataset?
I can't download it on the official website.

Thanks in advanced!

Please provide yolov4-tiny-obj.cfg

@achen353 - Please provide the 'yolov4-tiny-obj.cfg' so as to run the command [1] successfully. I checked the cfg/ folder and also search the whole repository but could not locate it.

[1] $./darknet detector demo data/obj.data cfg/yolov4-tiny-obj.cfg yolov4-tiny-obj_best.weights sample_videos/...

Please provide obj.data and obj.names

To make the command [1] run successfully, we also need obj.data and obj.names.

[1] $ ./darknet detector demo data/obj.data cfg/yolov4-tiny-obj.cfg yolov4-tiny-obj_best.weights

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.