Skip to content

Instantly share code, notes, and snippets.

@hunterjm
Last active July 20, 2020 17:11
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hunterjm/6f9332f92b60c3d5e448ad936d7353c3 to your computer and use it in GitHub Desktop.
Save hunterjm/6f9332f92b60c3d5e448ad936d7353c3 to your computer and use it in GitHub Desktop.
TensorFlow Object Detection Setup (Linux)
# Change this path to your config directory
CONFIG_DIR="/home/homeassistant/.homeassistant"
cd /tmp
# Clone the latest code from GitHub
git clone --depth 1 https://github.com/tensorflow/models.git tensorflow-models
# download protobuf 3.4
curl -OL https://github.com/google/protobuf/releases/download/v3.4.0/protoc-3.4.0-linux-x86_64.zip
unzip -a protoc-3.4.0-linux-x86_64.zip -d protobuf
mv protobuf/bin /tmp/tensorflow-models/research
# Build the protobuf models
cd /tmp/tensorflow-models/research/
./bin/protoc object_detection/protos/*.proto --python_out=.
# Copy only necessary files
mkdir -p ${CONFIG_DIR}/tensorflow/object_detection
touch ${CONFIG_DIR}/tensorflow/object_detection/__init__.py
mv object_detection/data ${CONFIG_DIR}/tensorflow/object_detection
mv object_detection/utils ${CONFIG_DIR}/tensorflow/object_detection
mv object_detection/protos ${CONFIG_DIR}/tensorflow/object_detection
# Cleanup
rm -rf /tmp/*
@SurfingSpider
Copy link

SurfingSpider commented Aug 20, 2019

I am having trouble running this sh on my Hassio install that is running on a Virtaulbox machine (host has i5 processor).

I download your script
wget https://gist.github.com/hunterjm/6f9332f92b60c3d5e448ad936d7353c3/raw/05018b802a67b93fa10390d2d3352cdca481133b/tensorflow_setup.sh

then take ownership
'chmod 777 tensorflow_setup.sh'

Then edit the sh to update the config folder location

# Change this path to your config directory
CONFIG_DIR="/config/"

but when I run the script it says.....

core-ssh:~# ./tensorflow_setup.sh
Cloning into 'tensorflow-models'...
remote: Enumerating objects: 3233, done.
remote: Counting objects: 100% (3233/3233), done.
remote: Compressing objects: 100% (2729/2729), done.
remote: Total 3233 (delta 594), reused 2076 (delta 426), pack-reused 0
Receiving objects: 100% (3233/3233), 370.69 MiB | 4.09 MiB/s, done.
Resolving deltas: 100% (594/594), done.
Checking out files: 100% (3058/3058), done.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   164    0   164    0     0    287      0 --:--:-- --:--:-- --:--:--   288
100   619    0   619    0     0    757      0 --:--:-- --:--:-- --:--:--   757
100 1357k  100 1357k    0     0   579k      0  0:00:02  0:00:02 --:--:--  971k
unzip: unrecognized option: a
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.

Usage: unzip [-lnojpq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

        -l      List contents (with -q for short form)
        -n      Never overwrite files (default: ask)
        -o      Overwrite
        -j      Do not restore paths
        -p      Print to stdout
        -q      Quiet
        -x FILE Exclude FILEs
        -d DIR  Extract into DIR
mv: can't rename 'protobuf/bin': No such file or directory
./tensorflow_setup.sh: line 16: ./bin/protoc: No such file or directory
mv: can't remove '/config/tensorflow/object_detection/data': Is a directory
mv: can't remove '/config/tensorflow/object_detection/utils': Is a directory
mv: can't remove '/config/tensorflow/object_detection/protos': Is a directory

if i unzip the files myself I just run into a different error when it tries to compile
./bin/protoc: No such file or directory

I am stuck. Any help would be greatly appreciated.

@olenoerby
Copy link

I am having trouble running this sh on my Hassio install that is running on a Virtaulbox machine (host has i5 processor).

I download your script
wget https://gist.github.com/hunterjm/6f9332f92b60c3d5e448ad936d7353c3/raw/05018b802a67b93fa10390d2d3352cdca481133b/tensorflow_setup.sh

then take ownership
'chmod 777 tensorflow_setup.sh'

Then edit the sh to update the config folder location

# Change this path to your config directory
CONFIG_DIR="/config/"

but when I run the script it says.....

core-ssh:~# ./tensorflow_setup.sh
Cloning into 'tensorflow-models'...
remote: Enumerating objects: 3233, done.
remote: Counting objects: 100% (3233/3233), done.
remote: Compressing objects: 100% (2729/2729), done.
remote: Total 3233 (delta 594), reused 2076 (delta 426), pack-reused 0
Receiving objects: 100% (3233/3233), 370.69 MiB | 4.09 MiB/s, done.
Resolving deltas: 100% (594/594), done.
Checking out files: 100% (3058/3058), done.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   164    0   164    0     0    287      0 --:--:-- --:--:-- --:--:--   288
100   619    0   619    0     0    757      0 --:--:-- --:--:-- --:--:--   757
100 1357k  100 1357k    0     0   579k      0  0:00:02  0:00:02 --:--:--  971k
unzip: unrecognized option: a
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.

Usage: unzip [-lnojpq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

        -l      List contents (with -q for short form)
        -n      Never overwrite files (default: ask)
        -o      Overwrite
        -j      Do not restore paths
        -p      Print to stdout
        -q      Quiet
        -x FILE Exclude FILEs
        -d DIR  Extract into DIR
mv: can't rename 'protobuf/bin': No such file or directory
./tensorflow_setup.sh: line 16: ./bin/protoc: No such file or directory
mv: can't remove '/config/tensorflow/object_detection/data': Is a directory
mv: can't remove '/config/tensorflow/object_detection/utils': Is a directory
mv: can't remove '/config/tensorflow/object_detection/protos': Is a directory

if i unzip the files myself I just run into a different error when it tries to compile
./bin/protoc: No such file or directory

I am stuck. Any help would be greatly appreciated.

Hi @SurfingSpider

Have you got the unzip application installed?

Try running

sudo apt install unzip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment