Use TensorFlow object detection API and MobileNet SSDLite model to train a pedestrian detector by using VOC 2007 + 2012 dataset

pip install pedestrian-detection-ssdlite==0.2



Use TensorFlow object detection API and MobileNet SSDLite model to train a pedestrian detector by using VOC 2007 + 2012 dataset

Forked from with many thanks :) This fork pins tensorfow version and includes dependencies.

Use pip install the package

pip install git+

After installation, you can use the API:

import cv2
from pedestrian_detection_ssdlite import api
from matplotlib import pyplot as plt

img = cv2.imread('test_img/example.jpg')
bbox_list = api.get_person_bbox(img, thr=0.6)

for i in bbox_list:
    cv2.rectangle(img, i[0], i[1], (125, 255, 51), thickness=2)

plt.imshow(img[:, :, ::-1])

and you will get the list of person bbox: [[(267, 62), (343, 270)], [(201, 65), (255, 227)], [(187, 64), (228, 169)]]

Use the api and pretrained model that I provided

Try, and I also provided a simple interface for using model, if you don't want to know the detail, please just copy whole api directory to your project and follow the way in, you will know how to use it.

The model was trained by using Tensorflow object detection API, and there are tons of good tutorial, so I would not explain too much here.

There are some useful tutorials link:


There are some classical scientific paper about modern object detection and the algorithm in Tensorflow Object Detection API

  1. RCNN:
  2. FastRCNN:
  3. FasterRCNN:
  4. YOLO:
  5. SSD:
  6. MaskRCNN:

Training step

  1. git clone
  2. Prepare VOC dataset (we took VOC 2012 + 2007 for example)
  3. Edit and modify to the version that extract only one class, I used "person" here for example
  4. Edit pascal_label_map.pbtxt and put one class called "person"
  5. ./
  6. Make training and validation dataset to tfrecord format
  7. Find the proper model and detection algorithm for yourself, I took MobileNet SSDlite for example here. You can find some information in Tensorflow Object Detection API's website
  8. Download proper pretrained model from tensorflow object detection API model zoo, because we usually DO NOT train the model from scratch, instead, we will use the pretrained model from Google and do transfer learning, you can find tons of pretrained model of Tensorflow Object Detection API here:
  9. Find the proper config file for your model and algorithm, put it into directory, I used ssdlite_mobilenet_v2_coco.config for example. You can find the config in models/research/object_detection/samples/configs/, and modify some part (training dataset path, pretrained model ckpt path) of config file to your custom dataset.
  10. Use ./ and start train the model
  11. After training model, you will find there are many ckpt model in train_logs directory, use models/research/object_detection/ to freeze ckpt model to pb model

The tutorial is really rough, please take a look from others tutorial that I provided.