MingtaoGuo / RetinaNet_TensorFlow

Implementation of RetinaNet (focal loss) by TensorFlow (object detection)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RetinaNet_TensorFlow

Implementation of RetinaNet by TensorFlow (object detection)

Introduction

Focal Loss

def focal_loss(logits, labels, alpha=0.25, gamma=2):
    pos_pt = tf.clip_by_value(tf.nn.sigmoid(logits), 1e-10, 0.999)
    fl = labels * tf.log(pos_pt) * tf.pow(1 - pos_pt, gamma) * alpha + (1 - labels) * tf.log(1 - pos_pt) * tf.pow(pos_pt, gamma) * (1 - alpha)
    fl = -tf.reduce_sum(fl, axis=2)
    return fl

How to use

Dataset

Pascal Voc: http://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar

Training phase

  1. Downloading the pre-trained model of ResNet50, and put it into the folder resnet_ckpt

    Address: http://download.tensorflow.org/models/resnet_v2_50_2017_04_14.tar.gz

  2. According to your own dataset, modify the config.py by yourself

  3. Executing train.py

Testing phase

  1. Changing the IMG_PATH or VIDEO_PATH in test.py for testing

  2. Executing test.py

    Model we trained: https://drive.google.com/open?id=1_j-bjQ_SWT3txqCabM8_Ny0IMUqTb8Lk

Requirement

  1. python
  2. tensorflow
  3. pillow
  4. numpy
  5. cv2

Results

Total Loss Class Loss Box Loss

Reference

[1] Lin, Tsung-Yi, et al. "Focal loss for dense object detection." Proceedings of the IEEE international conference on computer vision. 2017.

Author

Mingtao Guo

About

Implementation of RetinaNet (focal loss) by TensorFlow (object detection)

License:MIT License


Languages

Language:Python 100.0%