Improving Blue Iris with Home Assistant, TensorFlow, and Pushover [SIMPLIFIED!]

@TaperCrimp

Thanks for this guide. However, I am very new to all of this.

First of all, does this need Internet connection to work? Will it send snapshots from my IP Cameras to the “cloud” for processing?

Do you mean, I need to go to my Synology Docker GUI and download the latest tensorflow image from the registry and then launch it as per Docker  |  TensorFlow ? The instruction at Docker  |  TensorFlow is quite confusing to me too. Since I only use Docker via the GUI, I have no idea how to get started.

Which example should I follow? CPU-only images or GPU-enabled images? Which one is recommended? My Synology NAS is self-built using GIGABYTE GA-H97N-WIFI Motherboard. It has Integrated graphic processor.

I haven’t used it in a NAS before, but does the Synology Docker GUI allow you to enter the container? From the command line it’d be something like docker exec -it container_name bash. Personally I use Portainer to manage mine. Once you’re in the container you can run those steps.

Close but no cigar :). You’d run the TensorFlow setup in the Home Assistant container. It doesn’t need a separate one. Does that UI give you the ability to run bash within the Home Assistant container?

I go to Details > Terminal > Create and see this.

Is that what you are referring to?

What’s next? Do execute pip3 install tensorflow==1.11.0

I think I finally got it thanks to your guide and @robmarkcole’s guide.

From the above terminal, I do this…

  1. pip3 install tensorflow==1.11.0
  2. Downloaded the zip file from https://github.com/robmarkcole/tensorflow_files_for_home_assistant_component
  3. Extract the content and put the tensorflow folder into HA config directory.
  4. cd /config/tensorflow
  5. curl -OL http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
  6. tar -xzvf faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
  7. Finally, added this in the the HA configuration…

image_processing:
  - platform: tensorflow
    scan_interval: 20000
    source:
      - entity_id: camera.cam_dining
      - entity_id: camera.cam_couch
    model:
      graph: /config/tensorflow/faster_rcnn_inception_v2_coco_2018_01_28/frozen_inference_graph.pb
      categories:
        - person

Now, it can detect the number person in the camera. Much more accurate than Classificationbox.

Gents, if you install a package in the container, wont it disappear when it restarts?

I have installed tensorflow inside the HA container and I have restarted the HA container multiple times and it is fine.

Thank you very much. It’ll be deleted when you upgrade.

using the tensorflow container will be the permanent fix for docker users.

You could be right. I will confirm it later.

thank you. Do share the result if possible.

I’ve got the HA docker container installed like this:

docker run -d --name="home-assistant" -v /opt/home-assistant:/config \
--restart always \
-v /etc/localtime:/etc/localtime:ro --net=host \
homeassistant/home-assistant

Most of what I need is in there, although I’d have to reinstall the python component.

EDIT: I took a look at the container and it has the following files:

root@docker:/usr/src/app# pip3 uninstall tensorflow
Uninstalling tensorflow-1.11.0:
  Would remove:
    /usr/local/bin/freeze_graph
    /usr/local/bin/saved_model_cli
    /usr/local/bin/tensorboard
    /usr/local/bin/tflite_convert
    /usr/local/bin/toco
    /usr/local/bin/toco_from_protos
    /usr/local/lib/python3.6/site-packages/tensorflow-1.11.0.dist-info/*
    /usr/local/lib/python3.6/site-packages/tensorflow/*
Proceed (y/n)? n

I’m guessing I could change export PYTHONUSERBASE=/config/deps to get the python components to install in the persistent volume. However, that wouldn’t include the other components unless they’re in the image by default. I’d love to run it in a standalone container, but getting the HA to query the TensorFlow API is likely beyond my abilities.

Thank you very much for the info. I have nearly the same.
The package will definitely need reinstalling when you upgrade HA as it doesn’t contain it.

that’s why we need to find out how to use their (tensorflow) container. :wink:

I guess an easy “patch” would be to add the command:

docker exec -it homeassistant /bin/bash pip3 install tensorflow==1.11.0

to whatever upgrade script you use

That’s probably a much better solution. I don’t feel like creating a docker-compose script and just went with this instead:

docker run -d --name="home-assistant" -v /opt/home-assistant:/config \
--restart always \
-v /etc/localtime:/etc/localtime:ro --net=host \
homeassistant/home-assistant
sleep 30
docker exec -it home-assistant /bin/bash pip3 install tensorflow==1.11.0
docker restart home-assistant

This would only be when I manually recreate it. I use watchtower to keep them updated and might have to work something into that.

I created a simple script to update hass. I also use watchtower but didnt want to automate it because of breaking changes. I manually upgrade after a release.

I just updated HA to the latest version by following the official guide for Synology Docker, i.e…

  1. Download the latest image.
  2. Stop the container.
  3. Clear the container.
  4. Start the container.

And the tensorflow component still works.

1 Like

Yeah, same here. I’m guessing the instructions are already outdated and it’s included by default.

It still works without any modifications on the 0.83.2 release. Looks like we’re good.

1 Like

I have hassio running on debian.

When I run docker exec -it homeassistant /bin/bash pip3 install tensorflow==1.11.0

I get the following errors:
/usr/local/bin/pip3: line 4: import: command not found
/usr/local/bin/pip3: line 5: import: command not found
/usr/local/bin/pip3: line 7: from: command not found
/usr/local/bin/pip3: pip3: line 10: syntax error near unexpected token (' /usr/local/bin/pip3: pip3: line 10: sys.argv[0] = re.sub(r’(-script.pyw?|.exe)?$’, ‘’, sys.argv[0])’

Any suggestions how to fix these errors.

I don’t believe you need to run that command in 0.83.1 or 0.83.2, at least from my experience.