Tensorflow step-by-step guide

Hi all
I’m writing up a step-by-step guide to using the new Tensorflow component with Hassbian. Its on Hackster, currently you need to the URL to access it, but I’m seeing feedback before making it live and discoverable to the wider community.
Cheers

17 Likes

This is a detail you don’t need to worry about, but what’s required is to select an appropriate and place it in the configuration directory.

Word missing after "appropriate”

1 Like

Hi Rob, please consider adding the docker option… thanks

1 Like

Great! Hoping it will be supported by hassio in the future.

Strange.following the tutorial ends up in openalpr image processing…had this installed but now deactivated there’s no temsorflow in dev states in hass

Hi,
The tutorial is great, the instalation is covered in great detail but it’s IMO missing the most important part which is how to really make this whole tensorflow thing usefull and automate something with it. Maybe you should follow some end-to-end usecase and explain e.g. how to turn on a TV if someone sits on a couch or how to sound a horn if kid is detected close to the stairs/oven or something like that. But if you consider that out of scope of your tutorial you may at least link an article that covers that part.

In my case i have it on my frontdoor (Doorbird) :

Which gives me an output of:

You can use templating to grab the correct thing you want:

car_on_driveway:
  friendly_name: 'Vio auto'
  value_template: > 
                  {% if states.image_processing.tensorflow_voordeur_live.attributes.matches.car[0].score|float >= "90"|float %}
                    true
                  {% else %}
                    false
                  {% endif %}

Which gives me a nice:

image

And so you can use that for your automation.

A word of caution here though, if you have multiple cars in the picture it won’t work with the template above. Since its my driveway there is always 1 car only. It sometimes comes back with persons too but thats fine.

3 Likes

Really cool. Hoping for hass.io support!

2 Likes

could you help me? i’m not able to set up tensorflow on my pi3, got this error:
[homeassistant.components.image_processing.tensorflow] No TensorFlow Object Detection library found! Install or compile for your system following instructions here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.m

tensorflow is installed, and object_detection files are in folder /home/homeassistant/.homeassistant/tensorflow/object_detection

this is my config:

  • platform: tensorflow
    scan_interval: 10000
    source:
      - entity_id: camera.ip_cam_ingresso
      - entity_id: camera.ip_cam_cancello
    file_out:
      - "/tmp/{{ camera_entity.split('.')[1] }}_latest.jpg"
      - "/tmp/{{ camera_entity.split('.')[1] }}_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"
    model:
      graph: /home/homeassistant/.homeassistant/tensorflow/frozen_inference_graph.pb
      labels: /home/homeassistant/.homeassistant/tensorflow/object_detection/data/mscoco_label_map.pbtxt
      model_dir: /home/homeassistant/.homeassistant/tensorflow
      categories:
        - category: person

You have to install the following packages (on Hassbian/Raspbian) as well:

$ sudo apt-get install libatlas-base-dev libopenjp2-7 libtiff5

Copied from https://www.home-assistant.io/components/image_processing.tensorflow/

I had the same error as you but had missed that step, and it works. However, HA crashes when I try to do a scan with Tensorflow.

Hi @FredF, i’ve just the last version installed but ssame problem :frowning:
could it be something wrong in my config?

libatlas-base-dev is already the newest version (3.10.3-1+rpi1).
libopenjp2-7 is already the newest version (2.1.2-1.1+deb9u2).
libtiff5 is already the newest version (4.0.8-2+deb9u2).

image

At night it still works ‘ok’ too. But if you look at where the “car 96.4%” is, you can see a couple of cars there. So if i go to work it will still detect with a high accuracy that it detects a car, the one in the back.

Is there a way to say that the minimum size of the box needs to higher then xx? Can we use some smart template for that somehow? And in my template example, if it first matches a small car then the big one, it would fail since i check on the first one.

Funny stuff but still has some tweaking to make it perfect but almost there :slight_smile:

p.s. i would love to see some setups where we only check on say cars or persons or faces. I presume that would safe cpu performance too if you only check on that.

1 Like

@riemers Have you tried configuring the area to limit detection to your region-of-interest?

Has anyone got it to work on a Raspberry Pi, without Home Assistant crashing when Tensorflow tries to perform a scan?

@dvd78, sorry I don’t know. I did a fresh install, so that might work. But maybe not worth it having to reconfigure stuff, since it just crashes (at least for me).

i played with the area too, but so far it always takes the full 100% image from what i have seen. Might be a bug?

In my case, it was detecting the cars from my neighbors (too accurate).

. I ended up limiting the area and it works perfectly.

1 Like

Nice. Are you running it on a Raspberry Pi?

I am running it on an Intel NUC (Skull Canyon). Pi should work, but it will be slower. I am using it to make my security cameras smarter (send actionable notifications when person or car detected, for example) and it works very well.

+1 hoping for hassio support.

3 Likes

OK, cool! Unfortunately it does not seem to work on a Raspberry Pi. It just crashes for me when I try to perform a scan. According to the tutorial by @robmarkcole (great job btw!) it sounds like it should work though, but I can’t figure out why it crashes.