Week Project-YOLO V2 Training

This is a starter implementation of YOLOv2 model for object classification(1 class) and detection using a pretrained weight. My Goal is to detect the Red Blood Cell(RBC) which often involves identifying and characterizing patient blood samples.

Red Blood Cell datasets

Reference: Datasets download
In RBC_dataset directory, 366 annotations(.xml) are in Annotations directory, and corresponding images(.jpg) in JPECImages directory. XML files include labelled data in the context of object detection with corresponding bounding box coordinates and labels.

Environment

Ubuntu 16.04.3 LTS
Anaconda3-4.5.11
Cuda v7.5.17
Tesla K40c

IMG-BLOG


parse_annotation

In preprocessing.py, parse_annotation function is to transfer all xmls into a list, and then output 'all_imgs' and 'seen_labels' to count objects in all classes. parse_annotation transfers the format like :

IMG-BLOG


BatchGenerator

BatchGenerator is a function to suit all YOLO augmentation needs. Its output structure is a multi-dimensional array as shown below. 'x_batch' includes train (RGB) images, and 'y_batch' is the ground truth for calculating loss value. The one-hot encoded 'class' in (x, y, h, w, conf, class) can also express as (x, y, h, w,conf, class0, class1, class2,...) based on how many classes in datasets.

IMG-BLOG


Training Work Flow

IMG-BLOG


Tensor Board

There are total 18 epochs and it stopped because we applied 'EarlyStopping' callback function during my training process. 'EarlyStopping' stops training when the validation data set grows several times.

IMG-BLOG


Testing Work Flow

In testing, we fed an (RGB) images as an imput, and obtained a multi-dimensional array(1*13*13*5*6). It contains 13*13 grids, each grid has 5 box candidates, and each box have 6 values (x,y,w,h,p,class). Then, we filtered and removed the box with low probability(5th element p). In the end, draw the bounding boxes to show the object.

IMG-BLOG


Test

IMG-BLOG

CODE

Code Here