Question on dlib component

Same problem here!
Enclosed the log and yaml!

camera:

  • platform: local_file
    file_path: /tmp/image.jpg

image_processing:

  • platform: dlib_face_detect
    source:
    • entity_id: camera.local_file

017-05-22 23:01:46 ERROR (MainThread) [homeassistant.helpers.entity] Update for image_processing.dlib_face_local_file fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py”, line 222, in async_update_ha_state
yield from self.async_update()
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/image_processing/init.py”, line 140, in async_update
yield from self.async_process_image(image)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/image_processing/dlib_face_detect.py”, line 71, in process_image
self.process_faces(face_locations, len(face_locations))
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/image_processing/microsoft_face_identify.py”, line 111, in process_faces
self.hass.loop, self.async_process_faces, faces, total).result()
File “/usr/lib/python3.4/concurrent/futures/_base.py”, line 395, in result
return self.__get_result()
File “/usr/lib/python3.4/concurrent/futures/_base.py”, line 354, in __get_result
raise self._exception
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/util/async.py”, line 167, in run_callback
future.set_result(callback(*args))
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/image_processing/microsoft_face_identify.py”, line 137, in async_process_faces
face.update({ATTR_ENTITY_ID: self.entity_id})
AttributeError: ‘tuple’ object has no attribute ‘update’

Same errors occuring here. It seems to happen when it does see a face.

Hi,

For me none errors in the logs even if it doesn’t detect face…

Same here!

2017-07-15 20:43:39 ERROR (MainThread) [homeassistant.helpers.entity] Update for image_processing.dlib_face_garage fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py", line 222, in async_update_ha_state
    yield from self.async_update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/image_processing/__init__.py", line 140, in async_update
    yield from self.async_process_image(image)
  File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
  File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
  File "uvloop/future.pyx", line 101, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108900)
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/image_processing/dlib_face_detect.py", line 71, in process_image
    self.process_faces(face_locations, len(face_locations))
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/image_processing/microsoft_face_identify.py", line 111, in process_faces
    self.hass.loop, self.async_process_faces, faces, total).result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/util/async.py", line 167, in run_callback
    future.set_result(callback(*args))
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/image_processing/microsoft_face_identify.py", line 137, in async_process_faces
    face.update({ATTR_ENTITY_ID: self.entity_id})
AttributeError: 'tuple' object has no attribute 'update'

@patvdleer yes I found this bug too and I’m testing/working on a fix now.

If you want, you can test this debug code at https://github.com/tchellomello/home-assistant/tree/dlib_troubleshooting

Could you report this issue as an official problem? The branch above should take care of this problem. Dlib is working for me now and I’m also working on extending some options.

One of the options that I’m also testing is an ability see the images that are being captured or ignore by dlib. To do this, I’ve extended the component to save the image on some different conditions. So if an image has a face it will be saved on a directory when the option keep _images_with_faces is True. When keep_images_without_faces is True, all captured images also will saved in case a not face recognized.

The second part is with face identification. If is a known face combined with the option ‘keep_known_faces’ the image will be saved too. And pictures with faces but without a known face will also be saved that will help to understand the precise the sensor is. Of course this is intended to be used on debug and maybe we need to come with better names. Please let me know if you think this is useful. For me it was.

- platform: dlib_face_detect
  keep_images_with_faces: True
  keep_images_without_faces: False
  source:
    - entity_id: camera.amcrest_driveway
      name: "Face Detection"

- platform: dlib_face_identify
  keep_known_faces: True
  keep_unknown_faces: True
  source:
    - entity_id: camera.amcrest_driveway
      name: "Face Identification"
  faces:
    mmello: /home/hass/.homeassistant/faces/mmello.png
    mmello-fail: /home/hass/.homeassistant/faces/mmello-fail.jpg

The directories will be created automatically under the same directory where configuration.yamlfile is sitting on. For example:

(ha-py36) ↪ ll /home/mdemello/.homeassistant_tests/
total 3.4M
-rw-rw-r--.  1 mdemello mdemello  269 Jul 15 02:08 automations.yaml
-rw-rw-r--.  1 mdemello mdemello  689 Jul 11 03:23 cameras.yaml
-rw-rw-r--.  1 mdemello mdemello  897 Jul 15 00:09 configuration.yaml
drwxrwxr-x. 32 mdemello mdemello 4.0K Jul 11 01:19 deps/
drwxrwxr-x.  2 mdemello mdemello  20K Jul 15 02:08 dlib_detect_with_faces/
drwxrwxr-x.  2 mdemello mdemello  20K Jul 15 02:08 dlib_detect_without_faces/
drwxrwxr-x.  2 mdemello mdemello 4.0K Jul 15 02:08 dlib_identify_known_faces/
drwxrwxr-x.  2 mdemello mdemello  20K Jul 15 02:08 dlib_identify_unknown_faces/
-rw-rw-r--.  1 mdemello mdemello    0 Jul  9 23:47 groups.yaml
-rw-rw-r--.  1 mdemello mdemello 534K Jul 15 02:08 home-assistant.log
-rw-r--r--.  1 mdemello mdemello 2.8M Jul 15 02:08 home-assistant_v2.db
-rw-rw-r--.  1 mdemello mdemello  517 Jul 15 00:31 image_processing.yaml
drwxrwxr-x.  2 mdemello mdemello 4.0K Jul 11 01:18 python_scripts/
-rw-rw-r--.  1 mdemello mdemello 4.0K Jul  9 23:50 secrets.yaml
-rw-rw-r--.  1 mdemello mdemello  146 Jul 15 00:11 switches.yaml

Please let me know if that worked for you.
mmello

The issue has been reported, I’ll checkout the branch after lunch and see if I can dive in the code and help you fix it.

https://github.com/home-assistant/home-assistant/issues/8493

1 Like

Can you confirm if the issue is fixed in 0.49?

@arsaboo yes the issue happens on 0.49 and dev.

@patvdleer I’ve submitted the PR https://github.com/home-assistant/home-assistant/pull/8515 to address this problem.

Please refer to the PR for further information on how to configure it if you want to test it.
mmello

Hi…

While installing cmake, I get the following error… Could some one help me fix this.? Thanks in advance.
The installation is being done on Raspberry PI3 -All-in-one HA …

CMake Error at /tmp/pip-build-mu96tn0d/dlib/dlib/cmake_utils/add_python_module:116

(message):
Boost python library not found.
Call Stack (most recent call first):
CMakeLists.txt:6 (include)
– Configuring incomplete, errors occurred!
See also "/tmp/pip-build-

mu96tn0d/dlib/tools/python/build/CMakeFiles/CMakeOutput.log".
error: cmake configuration failed!

----------------------------------------

–compile" failed with error code 1 in /tmp/pip-build-mu96tn0d/dlib/

Hi

Have you test tout do that before ?
$sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev

Hi… Thanks for suggesting… Installed those 3 and tried to compile cmake which went through. However, installation of face_recognition failed and HA started hanging / crashed.

Does it really work in a Raspberry PI3 All-in-One HA installation.?

On a Rpi3 i don’t know, for me HA is installed on a VM on a ESX server…

Additional dependencies:
sudo apt-get install libjpeg-dev zlib1g-dev liblapack-dev

Hi all,
for those who made this component work. How well does it work? How high is your accuracy ?
Also, will it be able to do inference on PI? Or need better CPU to run on?

Where did you do model training if any?

How does this component compare to Microsoft Face recognition API? Their model must be better, but I wonder what the latency is for dlib vs Microsoft Face api?

Hi,

I tested that one year ago…
The Microsoft solution is connected to microsoft server i prefer avoid this type of architecture.
Nevertheless this solution is quite quickly.

I test DLIB component and on a correct server (XEON 3.9ghz) on a VM, it takes 4-5 seconds to recognize somebody and execute an automation.

For me it’s not enough quick to be integrated to my system… but it is fun :smile:

Have no idea how to get it work on Hassio on RPI3.
After container restarting installed packages (cmake and face_recognition) gone.

If you have a configuration that works on a normal install (not container based) and are willing to share that, I will figure out the container resolution. It maybe just mapping some files that’s required, similar to the t solution for Zwave configuration

Regards
Damian

Hey… i wonder if the configuration options keep_images_with faces and so on have it ever made into the master branch? I do not see those configuration options in the dlib documentation - why is that?

Also i tried to use this component on a Raspberry Pi3 but it slowed down the hole system - but the strange thing was that it did not take CPU or memory resources, so i don’t really understand why it almost blocked my Raspberry. This should not be an IO intensive task, right?
Has anyone achived to got this smoothly running on an RPi3 with camera.local_file as source?

Hi,
I have the same question as tom-x1 :slight_smile:

And I d’ont understand where the “face.jpg” are