This repository is useful tools for TensorFlow Object Detection API.
For only demo. Setup Python3.x, TensorFlow 1.x or TensorFlow 2.x, OpenCV.
Then execute following commnads, you can get object detection demo on Mac/Linux PC/Jetson Nano/Raspberry Pi.
$ cd && git clone https://github.com/karaage0703/object_detection_tools
$ cd ~/object_detection_tools/models
$ ./get_efficientdet_d0_coco17_tpu-32.sh
$ cd ~/object_detection_tools
$ python3 scripts/object_detection_tf2.py -l='./models/coco-labels-paper.txt' -m='./models/efficientdet_d0_coco17_tpu-32/saved_model/'
$ cd && git clone https://github.com/karaage0703/object_detection_tools
$ cd ~/object_detection_tools/models
$ ./get_ssdlite_mobilenet_v2_coco_model.sh
$ cd ~/object_detection_tools
$ python3 scripts/object_detection.py -l='models/coco-labels-paper.txt' -m='models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb'
Setup Python3.x and TensorFlow environment.
And get TensorFlow Models repository.
Execute following commands for download TensorFlow Object Detection API and change directory:
$ git clone https://github.com/tensorflow/models
$ cd models/research
Go to models/research
directory
Execute following command:
$ git clone https://github.com/karaage0703/object_detection_tools
Change directory object_detection_tools/models
and execute download script for downloading model file.
For example:
$ ./get_ssd_inception_v2_coco_model.sh
Execute following commands at object_detection_tools
after downloading ssd_inception_v2_coco_model data:
$ cd ~/object_detection_tools
$ python scripts/object_detection.py -l='models/coco-labels-paper.txt' -m='models/ssd_inception_v2_coco_2018_01_28/frozen_inference_graph.pb'
Using VoTT is recommended.
Export tfrecord data.
Put tfrecord data ./data/train
and ./data/val
directory.
Then, execute following command at object_detection_tools/data
directory:
$ ./change_tfrecord_filename.sh
SSD inception v2 example(fine tuning)
Change directory object_detection_tools/models
and execute download script for downloading model file:
$ ./get_ssd_inception_v2
Execute following commands for training model:
$ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
$ python object_detection/model_main.py --pipeline_config_path="./object_detection_tools/config/ssd_inception_v2_coco.config" --model_dir="./saved_model_01" --num_train_steps=1000 --alsologtostderr
notice: model_dir
must be empty before training
Convert from ckpt to graph file.
Execute following commands for converting from ckpt to graph file:
$ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
$ python object_detection/export_inference_graph.py --input_type image_tensor --pipeline_config_path object_detection_tools/config/ssd_inception_v2_coco.config --trained_checkpoint_prefix saved_model_01/model.ckpt-1000 --output_directory exported_graphs
Convert from pbtxt data to label data.
Execute follwing commands for converting from pbtxt data to label data:
$ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
$ python object_detection_tools/scripts/convert_pbtxt_label.py -l='object_detection_tools/data/tf_labl_map.pbtxt' > ./exported_graphs/labels.txt
Execute following command for testing trained model:
$ python object_detection_tools/scripts/object_detection.py -l='./exported_graphs/labels.txt' -m='./exported_graphs/frozen_inference_graph.pb'
This software is released under the Apache 2.0 License, see LICENSE.