1. 中文
    1. 在train_config中添加from_detection_checkpoint参数
    2. 更新训练时的summary
    3. 在eval.py中添加gpu_allow_growth参数
    4. 在train.py中添加gpu_allow_growth参数
    5. 在train.config中添加max_to_keep参数
    6. 网络添加FocalSigmoidClassificationLoss
  2. English
    1. Add from_detection_checkpoint parameter in train_config
    2. Remove some summaries when training
    3. Add gpu_allow_growth parameter in eval.py
    4. Add gpu_allow_growth parameter in train.py
    5. Add max_to_keep parameter in train_config
    6. Add FocalSigmoidClassificationLoss in model

代码仓库:https://github.com/lijiancheng0614/tensorflow_object_detection

修改TensorFlow Object Detection API,添加一些方便使用或新的功能。

中文

使用时记得添加PYTHONPATH:

1
2
# From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

以及编译protobuf:

1
2
# From tensorflow/models/
protoc object_detection/protos/*.proto --python_out=.

train_config中添加from_detection_checkpoint参数

增加加载模型所有参数和不加载模型的模式。

原来:

from_detection_checkpointbool型:

  • True: 加载detection模型参数中FeatureExtractor部分。

  • False: 加载classification模型参数。

现在:

from_detection_checkpointuint32型:

  • 3: 不加载模型参数(适用于train from scratch的情况。)

  • 2: 加载模型所有参数(适用于训练中断后重新加载checkpoint的情况。)

  • 1: 加载detection模型参数中FeatureExtractor部分。

  • 0: 加载classification模型参数。

修改文件:

  • trainer.py

  • core/model.py

  • protos/train.proto

  • meta_architectures/ssd_meta_arch.py

  • meta_architectures/faster_rcnn_meta_arch.py

更新训练时的summary

把histograms和first_clone_scope等summaries去掉。这样训练的event文件变小,方便tensorboard加载。

修改文件:

  • trainer.py

eval.py中添加gpu_allow_growth参数

eval.py中添加gpu_allow_growth参数,默认为True,即不占用GPU全部内存,而是动态申请显存。

修改文件:

  • eval.py

  • evaluator.py

  • eval_util.py

train.py中添加gpu_allow_growth参数

train.py中添加gpu_allow_growth参数,默认为True,即不占用GPU全部内存,而是动态申请显存。

修改文件:

  • train.py

  • trainer.py

train.config中添加max_to_keep参数

train_config中添加max_to_keep参数,默认为5,即保留最后5个checkpoint。如为0则保留所有的checkpoint。

修改文件:

  • trainer.py

  • train.proto

网络添加FocalSigmoidClassificationLoss

model中的loss中的classification_loss可使用focal_sigmoid

关于Focal loss,参考 https://arxiv.org/pdf/1708.02002.pdf

修改文件:

  • core/losses.py

  • builders/losses_builder.py

  • protos/losses.proto

English

Remember update PYTHONPATH:

1
2
# From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

And compile protobuf:

1
2
# From tensorflow/models/
protoc object_detection/protos/*.proto --python_out=.

Add from_detection_checkpoint parameter in train_config

Old:

bool from_detection_checkpoint

  • True: the checkpoint was an object detection model that have the same parameters with the exception of the num_classes parameter.

  • False: the checkpoint was a object classification model.

New:

uint32 from_detection_checkpoint

  • 3: don't load any variables.

  • 2: load all variables.

  • 1: load feature extractor variables from an object detection model, same as True.

  • 0: load feature extractor variables from a object classification model, same as False.

Modified files:

  • trainer.py

  • core/model.py

  • protos/train.proto

  • meta_architectures/ssd_meta_arch.py

  • meta_architectures/faster_rcnn_meta_arch.py

Remove some summaries when training

Remove summaries about histograms and first_clone_scope when training.

Modified files:

  • trainer.py

Add gpu_allow_growth parameter in eval.py

Add gpu_allow_growth parameter in eval.py, default value is True which means attempting to allocate only as much GPU memory based on runtime allocations.

Modified files:

  • eval.py

  • evaluator.py

  • eval_util.py

Add gpu_allow_growth parameter in train.py

Add gpu_allow_growth parameter in train.py, default value is True which means attempting to allocate only as much GPU memory based on runtime allocations.

Modified files:

  • train.py

  • trainer.py

Add max_to_keep parameter in train_config

Add max_to_keep parameter in train_config, default value is 5 which means the 5 most recent checkpoint files are kept. If 0, all checkpoint files are kept.

Modified files:

  • trainer.py

  • protos/train.proto

Add FocalSigmoidClassificationLoss in model

In config, model -> loss -> classification_loss can be focal_sigmoid, parameters: anchorwise_output, gamma.

Reference: https://arxiv.org/pdf/1708.02002.pdf

Modified files:

  • core/losses.py

  • builders/losses_builder.py

  • protos/losses.proto