Giter Club home page Giter Club logo

yolo-darknet-video-and-image-detection-traffic-signs's Introduction

YOLO Darknet: Traffic sign detection on image and video

result_traffic_sign

Download Traffic Sign Dataset

In this project, German Traffic Sign Detection Benchmark Dataset was used. Dataset includes the 900 training images (1360 x 800 pixels) in PPM format, the image sections containing only the traffic signs, a file in CSV format with the ground truth, and a ReadMe.txt with more details.

Note: Do not need to the download dataset, we will download it in training_YOLOv3_Darknet.ipynbb ๐Ÿฅณ

Converting Traffic Sign Dataset in YOLO Format

Open training_YOLOv3_Darknet.ipynb in Colab and run the code.

  • In the YOLO format, every image in the dataset has a single text file. If an image has no objects there is no text file for that image.
  • Inside the text file, each row contains the following information: The first element of each row is a class id, then bounding box properties (x, y, width, height). Bounding box properties must be normalized (0โ€“1). (x, y) should be the mid-points of a box.
images
โ†’ 0001.jpg
labels
โ†’ 0001.txt
 โ”œโ”€โ”€ class_id, x_centre, y_centre, width, height
  • Also we need to create the following files before training:
  โ”œโ”€โ”€ train.txt
  โ”œโ”€โ”€ test.txt
  โ”œโ”€โ”€ ts_data.data
  โ”œโ”€โ”€ classes.names

These files' formats are as following:

train.txt and test.txt

/content/FullIJCNN2013/00539.jpg
/content/FullIJCNN2013/00207.jpg
/content/FullIJCNN2013/00075.jpg
.
.

classes.names

prohibitory
danger
mandatory
other

ts_data.data

classes = 4
train = /content/FullIJCNN2013/train.txt
valid = /content/FullIJCNN2013/test.txt
names = /content/FullIJCNN2013/classes.names
backup = backup

Setting up Configuration Files

yolov3.cfg includes parameters for training, structure of CNN layers, last three YOLO layers.

filters = (classes + coordinates + 1) * masks

max_batches = classes * 2000 (not less than 4000)

steps = 80% and 90% of max batches (max batches represent total number of iterations for training)

For traffic sign dataset:

filters = (4 + 5) * 3 = 27
max_batches = 4 * 2000 = 8000
steps = 6400, 7200
classes = 4
batch = 32 (training), 1 (testing)
subdivisions = 16 (training), 1 (testing) - (represent number of minibatches in one batch)
  • Prepare yolov3_train.cfg and yolov3_test.cfg files according to your custom dataset following above instructions and put under the darknet/cfg/ location.

Training YOLOv3 in Darknet Framework

After preparation of all files we will train the the custom dataset with following command:

!./darknet detector train cfg/ts_data.data cfg/yolov3_train.cfg darknet53.conv.74 -dont_show

How to define the best weights after training?

Weights will be saved every 100 iterations in the following path. Now, we will define the best one to use for detection making sure that there is no overfitting.

โ”œโ”€โ”€ darknet/
    โ”œโ”€โ”€ backup/
        โ”œโ”€โ”€ yolov3_train_1000.weights
        โ”œโ”€โ”€   ...
        โ”œโ”€โ”€ yolov3_train_last.weights
        โ”œโ”€โ”€ yolov3_train_final.weights

There is special command in Darknet framework that calculates mAP.

!./darknet detector map cfg/ts_data.data cfg/yolov3_ts_train.cfg backup/yolov3_train_1000.weights

Continue checking for all weights in order to define the weights with biggest mAP.

Testing

  • Put traffic-sign-test.mp4 under the darknet/data/, and yolov3_train_1000.weights to darknet/weights/ location.
!./darknet detector demo cfg/ts_data.data cfg/yolov3_ts_test.cfg weights/yolov3_train_1000.weights data/traffic-sign-test.mp4 -out_filename traffic-sign-to-test.avi -dont_show

Inference on Image

Open the traffic_sign_image_detection.ipynb notebook and run the script for your test image.

Inference on Video

Open the traffic_sign_detection_on_video.ipynb notebook and run the script for your test video.

result_traffic_sign

yolo-darknet-video-and-image-detection-traffic-signs's People

Contributors

rumeysakeskin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

yolo-darknet-video-and-image-detection-traffic-signs's Issues

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.