Note that I used macOS High Sierra for this, but the idea should be the same regardless of your macOS. Also, if you have GPU on your local machine, and wanted to use that GPU for tensorflow, this tutorial is not for you
Step 1. Know the versions
Check first the needed python, and tensorflow versions. I used this repository as my lookup table. Since I am working on macOS High Sierra, and I wanted to use Python 3.x.x version, I picked the image below.
Step 2. Create python virtual environment
Since it is a very good practice to create virtual environments when making any projects, I decided to create one with Python 3.6.5. If you have no idea how to setup python virtual environments, you can check out this guide.
Step 3. Clone tensorflow models
Clone this repository.
Step 4. Setup the environment
Install tensorflow, and dependencies
Install the correct version of tensorflow for your python version, and machine. Make sure that your virtual environment is activated (workon virtualenv
)
pip install tensorflow==1.8pip install Cython
pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib
Compile Protobuf
On terminal, brew install protobuf
. For my machine, this downloaded protobuf-3.6.0.high_sierra.bottle.tar.gz. Run the following from tensorflow/models/research/
directory
# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.
If there are no errors and messages, it means that protobuf compiled correctly.
Add Libraries to PYTHONPATH
For this part, you have you options, you either update the PYTHONPATH from every new terminal that you will start (temporary), or you set up the PYTHONPATH on your ~/.bash_rc
or ~/.bash_profile
(permanent).
Option 1: Temporary update of PYTHONPATH
From terminal, run
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Option 2: Permanent update of PYTHONPATH
Edit your ~/.bash_rc
or ~/.bash_profile
and replace the above `pwd`
part to the absolute path of tensorflow/models/research
on your local machine
# ~/.bash_rc or ~/.bash_profile should include something like:
export PYTHONPATH=$PYTHONPATH:/PATH-TO/models/research:/PATH-TO/models/research/slim
Then from terminal, runsource ~/.bash_rc
or source ~/bash_profile
.
Now you’re good to do experiments with tensorflow object detection module.