This is an oriented object detector based on tensorflow object detection API. Most of the code is not changed except for those related to the need of predicinting oriented bounding boxes rather than regular horizontal bounding boxes.
Many tasks need to predict an oriented bounding box, e.g: Scene Text Detection. Check out the detection results: (Note that this code doesn't train model to recognize text. Only the bounding boxes are predicted)
For each predicted bounding boxes, in addition to the regular horizontal bounding box, we need to predict one oriented bounding box. Basically it means that we need to regress to an oriented bounding box. In this project, we simply regress to the encoded 4 corners of the oriented bounding boxes(8 values). See below equation for the encoding function. j is the index for each corner. g represents ground truth oriented bounding boxes. w_a and h_a is the anchor width and height, respectively.
There are many object detection framework to be used. We adopt this one as the basis for the following reasons:
It's easy to change the encoding scheme in the code. Simply changing the code in box_coders folder. The encoding using [R2CNN] (https://arxiv.org/abs/1706.09579) will be released soon. Training model with faster rcnn or ssd is easy to modify.
It's easy to change feature extraction CNN backbone by using slim nets.
Changing the network configuration setting is easy. For example, to change the different aspect ratios of the anchors used, simply changing the grid_anchor_generator in the configuration file.
It provides many supporting code such as exporting the trained model to a frozen graph that can be used in production(For example, in your c++ project). Check out my another project DeepSceneTextReader which used the frozen graph trained with this code.
You do not need to use blaze build to build the code. Simply run the code from the root directory for fast experiment.
added oriented related filed to the proto files. Please build them with
protoc protos/*.proto --python_out=.
added code for encode and decode oriented bounding boxes
Add code to predict the oriented bounding boxes for each proposal. At the same time the add code to calculate the oriented bounding boxes regression loss.
Use the code create_text_dataset.py to create the tfexample data files used for training. You can create ICDAR 2015 and ICDAR 2013 data for training.
If you are training faster rcnn inception resnet v2 model, you can download the pretrained weight from tensorflow model zoo.
See data/faster_rcnn_inception_resnet_v2_atrous_text.config for example configuration The parameter: second_stage_localization_loss_weight_oriented is the weight for the oriented bounding box prediction.
Example running script is provided: train_faster_rcnn_inception_resnet_v2.sh
Trained with default configuration with ResNet Inception V2 or ResNet 101 backbone on ICDAR 2013 + ICDAR 2015 training set. The performance on ICDAR 2015 dataset.
Backbone | Recall | Precision | F-1 |
---|---|---|---|
ResNet Inception V2 | 0.7371 | 0.8057 | 0.7699 |
ResNet 101 | 0.6861 | 0.8213 | 0.7476 |
To improve the performance, try changing the configuration settings. Many scene text detectors have more aspect ratios anchors for each location than that was used for regular object detection.
- Provide support for R2CNN training.
- Faster RCNN Faster RCNN paper.
- Tensorflow Object Detection API.
- R2CNN Reference paper for R2CNN.
- Dafang He. The Penn State University. hdfcraig@gmail.com http://personal.psu.edu/duh188/