Question on dlib component

Hi,

I setup Dlib component on my HomeAssistant.
It works fine, but is that possible to get the picture analyzed by the component ?

Hi…

I tried this and I get an error platform cannot be setup. Could you please advise me if there is anything more to be done besides just following what is said in the components doc. Thanks in advance.

Hi @KvRajan

I must to do that to avoid errors :

sudo apt-get install cmake
sudo pip3 install face_recognition==0.1.14

After that restart Home Assistant and all works !
The component face_recognition needs cmake to compile dlib.

1 Like

Hi…
Did you install any library or tool with apt-get for this to work.
Could you please provide the details how you made it work.
Thanks.

Oh ! That’s great and I was looking for such inputs only. Will try it out and revert. Thanks a million.

Hi…

I’m installing face_recognition and it is taking too long. First time, my system Raspberrry PI3 was frozen.
I rebooted it and trying again. Does it really take too long…? say over 15 minutes or so… The last message on the screen is
" Building wheels for collected packages: dlib, scipy
Running setup.py bdist_wheel for dlib … "

Is this normal or something, not right…?

thanks in advance.

Hi…

Further to the above, it came out with the following message:
Failed building wheel for scipy


Failed cleaning build for for scipy

and does not go further. system hangs and need to be rebooted.

Any advice how to get this working. Any pre-requisites missing…?

Hi

I installed that on a Ubuntu VM where home assistant is installed :yum:
So not on a raspberry
Any messages in syslog ?

Hi…
Bad luck in installing face_recognition. Did not go through. I tried on another PI. Got stuck somewhere in the middle and stopped.

Could you please advise what messages to look for and where ?
thanks in advance.

I tried installing dlib on my Pi3, it was compiling it’s modules for three hours before it finally failed. I just assumed it wasn’t something that could run on a Pi.

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/