Tensorflow Object Detection Tutorial #1 – Installation
In this tutorial we will install the Tensorflow Object Detection API and test it out using the object_detection_tutorial.ipynb file.
First we need to clone the Tensorflow models repository.
After we have cloned the repository we need to download Protobuf from this website.
Next we need to extract both of the folders using 7zip or winrar and while this is running we can install Cython, contextlib2, pillow, lxml, jupyter and matplotlib by typing:
pip install --user Cython pip install --user contextlib2 pip install --user pillow pip install --user lxml pip install --user jupyter pip install --user matplotlib
Then we need to go into models/research and use protobuf to extract python files from the proto files in the object_detection/protos directory.
The official installation guide uses protobuf like:
./bin/protoc object_detection/protos/*.proto --python_out=.
But the * which stands for all files didn’t work for me so I wrote a little Python script to execute the command for each .proto file.
import os import sys args = sys.argv directory = args protoc_path = args for file in os.listdir(directory): if file.endswith(".proto"): os.system(protoc_path+" "+directory+"/"+file+" --python_out=.")
This file needs to be saved inside the research folder and I named it use_protobuf.py. Now we can use it by going into the console and typing:
python use_protobuf.py Example: python use_protobuf.py object_detection/protos C:/Users/Gilbert/Downloads/bin/protoc
Lastly we need to add the research and research slim folder to our enviroment variables and run the setup.py file.
To add the paths to enviroment variables in Linux you need to type:
export PYTHONPATH=$PYTHONPATH:<PATH_TO_TF>/TensorFlow/models/research export PYTHONPATH=$PYTHONPATH:<PATH_TO_TF>/TensorFlow/models/research/object_detection export PYTHONPATH=$PYTHONPATH:<PATH_TO_TF>/TensorFlow/models/research/slim
On windows you need to at the path of the research folder and the research/slim to your PYTHONPATH enviroment variable (See Environment Setup) .
To run the setup.py file we need to navigate to tensorflow/models/research and run:
# From within TensorFlow/models/research/ python setup.py build python setup.py install
This completes the installation of the object detection api. Now we can try it out by going into the object detection directory and typing jupyter notebook to open jupyter.
Then you can open the object_detection_tutorial.ipynb file and run all cells.
That was all of this tutorial about how to install the Tensorflow Object Detection API. I hope you liked it and if you did please consider subscribing to the channel.