core: Tensorflow not available in Hassio

Tensorflow component, HA 0.82 on Hassio.

The docs state that tensorflow is included in Hassio, but it is not listed in the build logs nor requirements.txt. On following the setup process (here) and configuring the component, I do not get any cannot import tensorflow errors, but I get the following, indicating an import problem (as we expect):

Error while setting up platform tensorflow
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/image_processing/tensorflow.py", line 127, in setup_platform
    detection_graph = tf.Graph()
AttributeError: module 'tensorflow' has no attribute 'Graph'

@hunterjm @dale3h @arsaboo

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@frenck Have you considered including Tensorflow Light in hassio instead ? It’s a shrunk down TF for mobile and embedded devices. Still runs Pre-trained TF models. https://www.tensorflow.org/lite/guide/get_started

I might have some spare cycles to help in this area if there is interest.

It will be available with next release

@pvizeli Could you please elaborate. What will be available with which next release?

@robmarkcole 's suggestion makes a lot of sense to me. For faces we’d have to include an easy way for users to add custom faces and train, which excludes TF Lite, since it only allows inference but not training. That leaves people and cars which can be probably addressed with one of the good pre-trained models for object detection focused on 5-10 categories/classes. Recommendations?

Since full TF (and other popular frameworks with regression capability) doesn’t run well on RPI due to memory and computing constraints, it probably makes sense to look at trainable ML solutions that integrate with HASS as add-ons and remotely interface with a standalone GPU/TPU powered system.

It will be available with next release

The inference times look very good, certainly anything under 1s is acceptable. The models are small relative to full tensorflow, but I leave it to others to comment on if the size is acceptable to include in an image. I expect we will want to wait for tf2 official rather than chase a moving target or faff around with 1x. In my experience people are interested in 3 classes for detections - people, faces and cars, so we will want to cover these. However faces are only useful if you can then recognise trained faces, and none of the models will do this out of the box, so maybe we add faces later.

Update: Here is what I get with TF Lite on RPI4:

Model name Execution time Model size
mobilenet_v2_1.0_224_quant.tflite 222ms 3.6MB
coco_ssd_mobilenet_v1_1.0_quant_2018_06_29 353ms 4.1MB
mobilenet_v1_1.0_224.tflite 331ms 16.9MB
mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite Didn't find custom op for name 'edgetpu-custom-op' . Appears that its a model built for Coral that is not supported by the latest FOSS TF Lite package. 6.9MB

I would like to get some feedback whether the above combination of performance and size are reasonable in order to consider including some them as default implementation of the HASS image processing component?

TF Lite itself installed is about 1.5M plus a model of 3-10MB in size, we are looking at approximately 15-20MB budget for 2 default models (maybe object detection and face recognition).

If the performance and binary size are acceptable, I think it could be helpful for new users to get some of the AI benefits out of the box. With more powerful alternatives available via add-ons as needed. I see quite a bit of discussion on the forums from folks trying to setup object and face detection on HASS.

Thoughts?

I haven’t run the model without hardware acceleration yet, that would require installing tensorflow on the pi 😃 Currently coral-pi-rest-server is a standalone project but I have limited its scope purposefully so that it could be a Hassio addon