This page walks through the steps required to train an object detection model on a local machine. It assumes the reader has completed the following prerequisites:
- The Tensorflow Object Detection API has been installed as documented in the installation instructions. This includes installing library dependencies, compiling the configuration protobufs and setting up the Python environment.
- A valid data set has been created. See this page for instructions on how to generate a dataset for the PASCAL VOC challenge or the Oxford-IIIT Pet dataset.
- A Object Detection pipeline configuration has been written. See this page for details on how to write a pipeline configuration.
+data
-label_map file
-train TFRecord file
-eval TFRecord file
+models
+ model
-pipeline config file
+train
+eval
A local training job can be run with the following command:
# From the tensorflow/models/research/ directory
PIPELINE_CONFIG_PATH={path to pipeline config file}
MODEL_DIR={path to model directory}
NUM_TRAIN_STEPS=50000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1
python object_detection/model_main.py \
--pipeline_config_path=${PIPELINE_CONFIG_PATH} \
--model_dir=${MODEL_DIR} \
--num_train_steps=${NUM_TRAIN_STEPS} \
--sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \
--alsologtostderr
where ${PIPELINE_CONFIG_PATH}
points to the pipeline config and
${MODEL_DIR}
points to the directory in which training checkpoints
and events will be written to. Note that this binary will interleave both
training and evaluation.
Progress for training and eval jobs can be inspected using Tensorboard. If using the recommended directory structure, Tensorboard can be run using the following command:
tensorboard --logdir=${MODEL_DIR}
where ${MODEL_DIR}
points to the directory that contains the
train and eval directories. Please note it may take Tensorboard a couple minutes
to populate with data.