Tensorflow object detection API Notes
1 min readJul 31, 2019
Notes
Environment Setup
- install Tensorflow-gpu or Tensorflow CPU version (activate conda environment if necessary)
pip install tensorflow-gpu==1.3.0 # specify tensorflow version for gpu
pip install tensorflow==1.13.0 pip install --upgrade tensorflow # upgrade to latest tensorflow version
- Library dependencies setup
sudo apt-get install protobuf-compiler python-pil python-lxml
sudo pip install jupyter,matplotlib,pillow,lxml
protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
- Run testing.py
python object_detection/builders/model_builder_test.py
The result is shown below:
Train the model
python object_detection/train.py \
--logtostderr \
--pipeline_config_path=/home/guilins/github/rcnn-model-test/waldo_model/waldo_model.config \
--train_dir=/home/guilins/github/rcnn-model-test/waldo_model/trainpython object_detection/train.py \
--logtostderr \
--pipeline_config_path=/home/guilins/github/rcnn-model-test/model/mymodel.config \
--train_dir=/home/guilins/github/rcnn-model-test/model/trainpython object_detection/train.py \
--logtostderr \
--pipeline_config_path=/home/guilins/github/rcnn-model-test/mymodel/mymodel.config \
--train_dir=/home/woden/github/rcnn-model-test/mymodel/train
Evaluate the model
python object_detection/eval.py \
--logtostderr \
--pipeline_config_path=/home/guilins/github/rcnn-model-test/waldo_model/waldo_model.config \
--checkpoint_dir=/home/guilins/github/rcnn-model-test/waldo_model/train \
--eval_dir=/home/guilins/github/rcnn-model-test/waldo_model/eval
Tensorboard to check the current training status
tensorboard --logdir=/home/guilins/github/rcnn-model-test/waldo_model/train
Export the model
python object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path /home/guilins/github/rcnn-model-test/waldo_model/waldo_model.config \
--trained_checkpoint_prefix /home/guilins/github/rcnn-model-test/waldo_model/train/model.ckpt-200000 \
--output_directory /home/guilins/github/rcnn-model-test/waldo_model/exportpython object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path /home/guilins/github/rcnn-model-test/model/mymodel.config \
--trained_checkpoint_prefix /home/guilins/github/rcnn-model-test/model/train/model.ckpt-146987 \
--output_directory /home/guilins/github/rcnn-model-test/model/export