Face detection with Docker/Machinebox

Correct config. Yes I will also use automations to only classify images when needed

Thank you. I updated to HA 0.69 and put back your un-modified v0.2 facebox.py.
working fine.

1 Like

First of all great work. I am finding my way now in home assistent after using domoticz. What i ve been searching for for like 20 hours of browsing, i think this will help me to do what i want. I have a danalock v3 zigbee protocol. Working fine. So i can use my phone to open the lock, or by HA, and i ve ordered two zigbee remotes. But thats not what home automation is about ;-). I explored two options: for my kids during some hours of the day face detection for home entry and fingerprint entry. Fingerprint entry (reader to HA) waterproof and under 100 euro is possible only very ancient and hackable protocols (i know nobody will hack my system at 3 o clock in the afternoon when i am home). So option two, but after exploring rekocnition from amazon, and checking all possible videobells compatible with HA and 1000 other possibilities. Here it is. Keep up the good work!

1 Like

For those setting up ā€œmanual scanningā€ the config is:

- service: image_processing.scan (as opposed to  image_processing.service_scan)
  entity_id: image_processing.facebox_saved_images

@robmarkcole Rob, as you probably already know (since you created the teach.py script - thank you) when you re-start the container whilst using the free tier the taught faces are lost.

To address this I created this automation to try and auto-load the faces on container restart.
https://hastebin.com/utaboruhuy.bash

However, container re-start is so fast that sensor off state isnā€™t captured. Any Ideas?

Thank you.

Iā€™m pretty sure you can save a faces file and then load that at restart, rather than performing the training again

Yes you can on the paid tier. This is the variable
MB_FACEBOX_STATE_URL

It reloads the faces file, but you canā€™t download it on free tier

@juan11perez yes appears FacePrints arenā€™t available on free tier.

If Iā€™ve understood correctly, youā€™ve setup an automation which you want triggered when the sensor state is none, as happens when the FaceBox API is unavailable?

@robmarkcole yes thatā€™s right. I set up a simple ping, but doesnā€™t do the job.

The command sensor doesnā€™t turn off.

Is there another event that can trigger it?

Yes I see the problem. Iā€™ve searching the docs to see if theres a way to query the number of trained faces or query the container uptime, but I donā€™t seen anything. You?

Might be worth querying the FacePrint endpoints to see what response you get (Iā€™m on holiday with only a work laptop and no Machinebox access)

Rob, apologies. This can obviously wait.

I think I found the solution. There is a curl command for ā€œsimilar facesā€ which returns a json. All we have to do is point it to our own file with one of the faces weā€™re teaching and if the face is there it returns the name of the face. Since weā€™re comparing to the actual face weā€™ve taught it then itā€™s either there or not.
This is my command with the output:

https://hastebin.com/ipufafosor.scala

Problem solved :+1: Btw are you restarting your Machinebox often for a particular reason?

@robmarkcole again thank you for your help. Created the workaround based on your suggestion to query the container. (faceprint is not accessible in any way on free tier)

I have documented my process for reference - https://hastebin.com/tecatuhani.http

Not frequently restarting the container; however, In the event of reboot docker-compose is restarting everything and facebox will loose its content. I usually reboot once a week on a cron.

Thanks for the share. Are you happy to add your helper script to the same repo as the training script? I think it will be useful to group helpful scripts together

@robmarkcole
Of course yes. Please go ahead.
I hope I captured all steps

@juan11perez would you be interested in writing up your TTS/face detection setup as a project on Hackster.io? Iā€™d be happy to help, and would be great to have a good write up of use to coincide with release of component in 0.70.

https://www.hackster.io/home-assistant

@robmarkcole
Sure, iā€™ll work on a draft and share it when ready.

1 Like

Ok Rob, have a look at the draft. No sure if we add the re-load faces process.

Thanks @juan11perez great start, I would suggest adding a section on why we do this, what problem we are trying to solve. Also some images and backstory are always nice. I suggest we move this conversation off this thread now. If you have an account on Hackster you can continue the work there and invite me as a collaborator.
Cheers

Rob, added the draft and sent you a note

1 Like

Hi there, i have some performance / stability issues. Here we go: i have a synology ds218+ running home assistant 0.69.1 stable on docker. Running yardstick-facebox1 (other version had port issues - mentioned above by peteonus - with port 8080 i could not resolve, remapped them several times tried a lot of things, but still not working). Yardstick-facebox-1 runs smooth so no problems on my synology. I have a Dahua camera above my front door with face recognition (call it face tracking) it makes a photo of a persons face when in the specified facial area. It then puts the jpg file on the synology server. With Robā€™s great manual on github I installed folder watcher, the input text ā€˜last added fileā€™, the automation template action: data template etc, the shell command and the last automation action in the HA files works flawless. Every (last) face is presented in HA. Last stap facebox authentication proces. As I pointed out facebox working, with Robā€™s script uploaded a few faces and checked them in the console. Working again got 0 % on the beatles ;-). Somehow uploading large jpgā€™s did not work had to downsize them. Now I installed HASS 0.70 0.b1 beta and entered Robs component in the config.yaml after a reboot (and copying the old configuration file) i got huge performance issues. Donā€™t know if it is because of the facebox interactions or the beta version of hassā€¦ but I am allmost there so i would appreciate a little advice. Is there a way to get this working in 0.69 is there a complete pythonscript for 0.69? Thanx all