Tensorflow step-by-step guide

How did you limit it btw? It did not really listen to my limit options. I am now playing with:

  value_template: > 
                {% if states.image_processing.tensorflow_voordeur_live.attributes.matches.car %}
                  {% for cars in  states.image_processing.tensorflow_voordeur_live.attributes.matches.car %}
                    {% if cars.box[2] - cars.box[0] * cars.box[3] - cars.box[1]|float >= "0.65"|float %}
                      True
                    {% endif %}
                  {% endfor %}
                {% endif %}

Never played that much with templating but now i get like a number that is the size of the box. If its on your drive way the car is always way bigger then the rest. In your case it might still fail if a giant truck comes by :wink: (but you managed to remove that part)

I am using the config to limit the detection. See my config here.

@FredF you are probably running out of memory on the pi

Yes, I figured. I can see the memory go away in the terminal before it crashes. But why?

Did you actually get it to work on a Raspberry Pi or was it an assumption that it should work? I am running a fresh install of Rassbian on a Raspberry Pi 3B+ with nothing else installed on it.

Do you think I am doing something wrong? I followed your guide, what can I have missed that leads to this? Would really appreciate some help… Thanks!

Yes, its on a pi 3B+. Admittedly this is a development HA instance with no other components configured yet, but I wouldn’t expect that to make much of a difference, but maybe I’m wrong… Im assuming you are using Hasspbian?

OK! Yes, typo from me… sorry, I meant Hassbian.

What resolution are your images at?

I don;t think that matters, as they are downsampled before processing

OK, well I just checked and my image was just 750 px wide anyway so it wasn’t large to begin with.

If I comment out the Tensorflow config in configuration.yaml and start the Pi my memory looks like this:

Memory......: 74M used, 634M free, 927M in total

If I have the Tensorflow config in my yaml file, but do NOT trigger a scan, my memory usage goes up:

Memory......: 370M used, 326M free, 927M in total

As I said, this is without performing a scan (I have scan_interval to 100000). And then when I trigger a scan it crashes.

Is it supposed to eat up this much memory to begin with without being used?

top will tell you more about what is using memory.

Thanks. Running top without Tensorflow component activated:

Hass 5.2 % memory usage

Running top with Tensorflow component activated, but not performing a scan:

Hass 41.8 % memory usage

Is this normal usage just by activating the component?

The component is loading the model into memory before any use has taken place, see source here

OK, so then that’s not the problem if it’s expected.

Do you think it would it help to use a different model that’s more lightweight? I am just interested in detecting people.

Yes you should definitely experiment with different models. I will be happy to add info on performance of different models to the Hackster article, that would be useful

I’m running Hassio on Raspberry Pi 3B+. It’s already using 20-30% CPU on idle, 60% RAM, temps about 55C.

What would be the impact if I move to Hassbian and get Tensorflow running? I only have one camera. Is the performance still good? Or should I think about upgrading before trying Tensorflow?
Would it be possible to run Tensorflow on a micro instance in AWS or Azure? Would the communication still be a huge impact on my Pi?

Are there any lighter models than ssd_mobilenet_v2_coco or do I have to make one myself…?

Personally I would wait for TensorFlow support on Hassio

2 Likes

A mobile model will be lightweight but not optimised for home automation, so an even lighter model is possible

1 Like

Thought so, but since I got into HA a few months ago I can’t wait to try or add more stuff as you can see, even trying to do some cool stuff just because it’s interesting and Tensor flow is interesting and could be very useful for my automations. I was thinking on moving part of my smart home stuff to public cloud services like DB, websites and a VM (company offers me some usage for free).

Yes in my opinion a pi simply lacks the resources for intensive applications like object detection at a fast rate. You might be interested in Sighthound

1 Like

I understand. What would be the “next level” in terms of hardware if one would like to run Tensorflow without issues? I mean in comparison to a Raspberry Pi, what do you need to run it without problems (but not buying an expensive desktop computer)?