Skip to content

Instantly share code, notes, and snippets.

@tensorAI
Created January 30, 2019 15:02
Show Gist options
  • Save tensorAI/59a6173a7b6a061dd417fadb3894eeb0 to your computer and use it in GitHub Desktop.
Save tensorAI/59a6173a7b6a061dd417fadb3894eeb0 to your computer and use it in GitHub Desktop.
#object detection using tensorflow object detection API
#tensorflow >= 1.12.0
#!/bin/bash
sudo apt update
sudo pip install -U virtualenv # system-wide install
virtualenv --system-site-packages -p python2.7 ./tf_object_detection
source ./tf_object_detection/bin/activate # sh, bash, ksh, or zsh
pip install --upgrade pip
#install tensorflow
pip install --upgrade tensorflow-gpu
#install remaining libraries
sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
pip install --user Cython
pip install --user contextlib2
pip install --user jupyter
pip install --user matplotlib
pip install --user wheel
pip install --user pandas
#coco api installation
cd ~/tf_object_detection/
pwd
git clone https://github.com/cocodataset/cocoapi.git
cd ./cocoapi/PythonAPI
make
cd ..
cd ..
#download models and copy coco tools
git clone https://github.com/tensorflow/models.git
cp -r ./cocoapi/PythonAPI/pycocotools ./models/research/
#Manual protobuf-compiler installation and usage
cd models/research/
wget -O protobuf.zip https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
unzip protobuf.zip
#compile
./bin/protoc object_detection/protos/*.proto --python_out=.
#Add Libraries to PYTHONPATH
LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
var=$(printf 'export PYTHONPATH="${PYTHONPATH}:%s/slim"' "$LOCAL_DIR")
echo $var >> ~/.bashrc
#test the installation from /home/USER/ in a NEW terminal
#-------------------------------------------
#source ./tf_object_detection/bin/activate
#cd tf_object_detection/models/research/
#python object_detection/builders/model_builder_test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment