修改TensorFlow Object Detection API

代碼倉庫:https://github.com/lijiancheng0614/tensorflow_object_detection

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

中文

使用時記得添加PYTHONPATH:

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

以及編譯protobuf:

# 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:

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

And compile protobuf:

# 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章