Previous Article – https://wp.me/p6xoZs-3K
We are going to train an existing model. So we have to download the model and it’s configuration first.
You can go the tensorflow model zoo and download the model as you wanted, and in the downloaded tensorflow source folder direct to research/object_detection/samples/configs in this folder you can find configuration files, according to the model you use.
I use ssd_mobilenet_v1_coco_11_06_2017 model and ssd_mobilenet_v1_pets.config config file. Also you need pbtxt map file as below,
item {
id: 1
name: 'macncheese'
}
you can expand the items as you used the no of items for the training.
Then, you have to change the paths in the following section in the model configuration file:
num_classes: 1 # this is in model - ssd section to present no of labels we used to train
train_config: {
batch_size: 10
optimizer {
rms_prop_optimizer: {
learning_rate: {
exponential_decay_learning_rate {
initial_learning_rate: 0.004
decay_steps: 800720
decay_factor: 0.95
}
}
momentum_optimizer_value: 0.9
decay: 0.9
epsilon: 1.0
}
}
fine_tune_checkpoint: "model/ssd_mobilenet_v1_coco_11_06_2017/model.ckpt"
from_detection_checkpoint: true
load_all_detection_checkpoint_vars: true
# Note: The below line limits the training process to 200K steps, which we
# empirically found to be sufficient enough to train the pets dataset. This
# effectively bypasses the learning rate schedule (the learning rate will
# never decay). Remove the below line to train indefinitely.
num_steps: 200000
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
ssd_random_crop {
}
}
}
train_input_reader: {
tf_record_input_reader {
input_path: "Data_Set/train.record"
}
label_map_path: "model/object_detection_map.pbtxt"
}
eval_config: {
metrics_set: "coco_detection_metrics"
num_examples: 1100
}
eval_input_reader: {
tf_record_input_reader {
input_path: "Data_Set/test.record"
}
label_map_path: "model/object_detection_map.pbtxt"
shuffle: false
num_readers: 1
}
Be aware of the paths of specific files and the location of you going to run the train.py which is we are going to do next.
Now direct to research/object_detection/legacy and get the train.py script to start the training. Run the script as below,
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
if you get any error, run below command
set PYTHONPATH=<location>\research;<location>\research\slim Eg: set PYTHONPATH=C:\python\models\research;C:\python\models\research\slim
While you start training, you can check the status from tensorboard like below,
tensorboard --logdir='training'
Next Article – https://wp.me/p6xoZs-3T