Giter Site home page Giter Site logo

bikerider-detector's Introduction

Bike-rider Detector

This repository illustrates how to create a bike-rider detector using Tensorflow so that we can use the detector to count the number of bike-riders in the street.

Overview

  1. Collect images of bike-riders from Google and Pixabay.
  2. Label them with LabelImg
  3. Transfer learning from existing network using Tensorflow
  4. Result

In general, this repository's codes are largely adopted from the posting below: https://towardsdatascience.com/how-to-train-your-own-object-detector-with-tensorflows-object-detector-api-bec72ecfe1d9

Data Collection

I collected total 396 images with bike riders, 324 from Google image search and 72 from Pixabay. You can see the images in the data/training/image folder. Don't forget resize the scraped images before labeling. You can use resize_images.py under src folder.

Labeling

Then I annotated the region of bike riders in each image with LabelImg tool, which makes to labeling process much convenient. I assigned 'bikerider' label on bike riders. You can find annotations for each image under data/training/annotation.

Create dataset

  1. Split train and test dataset
  • use split_train_test.py under src
 python split_train_test.py --test_ratio=0.3
  • this will create csv files (train_labels.csv, test_labels.csv) under ../data/training/data
  1. Convert the two dataset into tfrecord format
  • use generate_tfrecord.py under src
  python generate_tfrecord.py \
    --csv_input=../data/training/data/train_labels.csv \
    --output_path=../data/training/data/train.record

  python generate_tfrecord.py \
      --csv_input=../data/training/data/test_labels.csv \
      --output_path=../data/training/data/test.record

Transfer learning

We are going to use Tensorflow Object Detection API to train a detector. See here to set up it.

Instead of training the detector from scratch, I used faster_rcnn_resnet101_coco as basis. Modify the path of the ckpt file accordingly in data/training/config/faster_rcnn_resnet101_coco.config (line 112). You may need to change the path of train.record, test.record, and object-detection.pbtxt at line 127, 129, 141, 143 as well.

Then run train.py of object detection api (change path accordingly).

# move to your tensorflow object detection directory
cd ~/repo/tensorflow/models/research
# change parameters accordingly
python object_detection/train.py \
--logtostderr \
--pipeline_config_path=/home/ubuntu/repo/bike-detector/data/training/config/faster_rcnn_resnet101_coco.config \
--train_dir=/home/ubuntu/repo/bike-detector/data/training/train

It took me ~3 hours with Amazon AWS p2.xlarge instance.

Result

Once training is done, you can use the trained network to detect bike riders. See the notebook: https://github.com/yonghah/bikerider-detector/blob/master/notebook/test-bikerider-detector.ipynb

You can download trained network from here: https://umich.box.com/s/ncqywd2d8nfahzt1nmz6e2218q61mmad

bikerider-detector's People

Contributors

yonghah avatar

Watchers

James Cloos 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.