Skip to content

Zalo aI 2020: Traffic sign detection using Retinanet and image tiling

Notifications You must be signed in to change notification settings

ptran1203/traffic_sign_detection

Repository files navigation

traffic sign detection Open In Colab

Solution for Zalo AI traffic signs detection.

Original implementation of RetinaNet by Srihari Humbarwadi

Dataset

https://www.kaggle.com/phhasian0710/za-traffic-2020/download

Method

After taking a quick look at the dataset, we can see that there are many small signs. Which makes the model hard to detect them. One of the possible methods in this scenario is Image Tiling

In detail, I will crop the image into a few parts with some overlaps, predict each part and the original image. Then combine the result using non-max suppression.

1. Image cropping

tiling

2. Predict on each part (the color looks strange because the images are pre-processed)

tiling

3. Predict on the whole image

tiling

3. Combine the results

tiling

Data augmentation

Data augmentation used for trainning includes:

  1. Random brightness adjustment (p=50%)
  2. Random contrast adjustment (p=50%)
  3. Auto crop a region contains at least 1 bouding box (p=50%)
  4. Random horizontal flipping (p=50%)
  5. Random gaussian blur or motion blur (p=50%)

Trainning

python3 train.py --input {image_dir}\
                  --backbone resnet50\
                  --batch-size 4\
                  --checkpoint-dir /content/weights

Inference

python3 prediction.py --input {image_dir}\
                      --output submission.json\
                      --weight weights/weight_resnet50.h5\   # weight file should has format weight_{backbone}.h5
                      --save-dir /content/inference_images   # or "" if you dont want to save images
                      --scales 896,1024                      # Separated by comma
                      --tiling                               # Apply tiling if provided, useful for small objects

Inference result

./images/pred_1.png ./images/pred_2.png ./images/pred_3.png


NOTE

This project is running on Google Colaboratory environment, so it may contain some issues when running on local machine, please don't hesitate to create a new issue