Giter VIP home page Giter VIP logo

yolov3_tiny-hardhat-detection_tensorflow's Introduction

Hardhat (Helmet) detection from construction site using YOLOv3_tiny with TensorFlow

1. Introduction

Hardhat detection using Yolov3_tiny

2. Requirements

  • tensorflow >= 1.8.0 (lower versions may work too)
  • opencv-python

3. Running demos

(1) Single image test demo using ckpt file:

python test_single_image.py ./data/demo_data/google_image.jpg

test image from google

detection result

test image from dataset

detection result

4. Training

Hardhat dataset: pascal voc format: https://drive.google.com/drive/folders/12WtXQyM-7jWvWPtCXZlnycsIK72ClHgu?usp=sharing

Dataset credits: https://github.com/wujixiu/helmet-detection

4.1 Data preparation

(1) annotation file

Generate train.txt/val.txt/test.txt files under ./data/my_data/ directory. One line for one image, in the format like image_absolute_path image size box_1 box_2 ... box_n. Box_format: label_index x_min y_min x_max y_max.(The origin of coordinates is at the left top corner.)

For example:

577 /home/rashid/YOLOv3_TensorFlow-master/data/my_data/GDUT-HWD/JPEGImages/01457.jpg 440 293 1 235 84 258 110 1 291 93 307 115 1 320 96 335 114
743 /home/rashid/YOLOv3_TensorFlow-master/data/my_data/GDUT-HWD/JPEGImages/00179.jpg 1300 956 1 503 80 674 313 1 258 1 423 222
...

NOTE: You should leave a blank line at the end of each txt file.

(2) class_names file:

Generate the data.names file under ./data/my_data/ directory. Each line represents a class name.

For example:

bird
car
bike
...

The COCO dataset class names file is placed at ./data/coco.names.

(3) prior anchor file:

Using the kmeans algorithm to get the prior anchors:

python get_kmeans.py

Then you will get 9 anchors and the average IOU. Save the anchors to a txt file.

The COCO dataset anchors offered by YOLO v3 author is placed at ./data/yolo_anchors.txt, you can use that one too.

NOTE: The yolo anchors should be scaled to the rescaled new image size. Suppose your image size is [W, H], and the image will be rescale to 416*416 as input, for each generated anchor [anchor_w, anchor_h], you should apply the transformation anchor_w = anchor_w / W * 416, anchor_h = anchor_g / H * 416.

4.2 Training

Using train.py. The parameters are as following:

$ python train.py -h
usage: train.py 

        net_name = 'the yolo model'
        anchors_name = 'the anchors name'
        body_name = 'the yolo body net'
        data_name = 'the training data name'

Check the train.py for more details. You should set the parameters yourself.

Some training tricks in my experiment:

the yolov3 using darknet53, the yolov3_tiny using darknet19

Credits:

The code is inspired from following repos :

https://github.com/wizyoung/YOLOv3_TensorFlow

https://github.com/Huangdebo/YOLOv3_tiny_TensorFlow

Dataset credits: https://github.com/wujixiu/helmet-detection

yolov3_tiny-hardhat-detection_tensorflow's People

Contributors

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