Face detection with Docker/Machinebox

@robmarkcole, I saw you have experience with ClassificationBox. Do you think this may be better suited than or used in parallel to FaceBox for what I’m trying to do, ie: count adults/kids/dogs/cat presence on a room by room basis?
I’m finding FaceBox works great for identification at the door, but the fact that faces need to face the camera can be an issue for this. Makes sense though, doesn’t it?
Does CassificationBox work in a similar fashion to FaceBox? ie. teach pictures, then let the engine do the identification job?
Your tips are much appreciated.

To count those objects, you will need object detection. Classificationbox can be used to assign images to one of its trained categories, and in a recent project I used it to classify images as containing a bird or not. However it is not doing object detection, so I can’t get the number of birds in an image. Checkout this article on object detection, but note I’ve not found a nice Dockerised version of the API we could easily use with HA. I therefore recommend you checkout Tagbox, which is pretrained with 1000’s of classes.

1 Like

Cheers for this Robin. Will have a look when possible!

1 Like

All, for those interested, I have created a docker image based on the face_recognition python libray. Part of this I have created an API which emulated the facebox api. Meaning you can use the facebox component in Home Assistant, but then using the ip address and port in the HA configuration of the alternative docker setup . Created it for personal use (so do not expect intensive support) , but might be usefull for others.
https://github.com/RdeLange/robinvision

5 Likes

Fantastic @RdeLange, this is something I was hoping to do at some point. Could it be released as a Hassio addon? The requirements don’t look too bad

Podcast episode on Machinebox/Facebox

1 Like

@robmarkcole I see in your latest PR you removed the teach service. Is this being permanently removed or is there some other way to teach Facebox faces within HA?

Thats incorrect, teach service hasn’t changed, but the events it fired have been removed. Authentification is added

if the events are removed will i still get a notification when a teaching service is successful?

@Maaniac This info is still in the logs so you can use an automation to receive a notificaiton when you train a face:

- id: '1533703568569'
  alias: Face taught
  trigger:
  - event_data:
      service: facebox_teach_face
    event_type: call_service
    platform: event
  condition: []
  action:
  - service: notify.pushbullet
    data_template:
      message: '{{ trigger.event.data.service_data.name }} taught 
      with file {{ trigger.event.data.service_data.file_path }}'
      title: Face taught notification

Any errors on teaching will be reported in the logs. If you enable system_log events:

system_log:
  fire_event: true

you can create an automation to receive notifications on Facebox errors:

- id: '1533703568577'
  alias: Facebox error
  trigger:
    platform: event
    event_type: system_log_event
  condition:
    condition: template
    value_template: '{{ "facebox" in trigger.event.data.message }}'
  action:
  - service: notify.pushbullet
    data_template:
      message: '{{ trigger.event.data.message }}'
      title: Facebox error

Here is an article on setting up an Amazon container to host Facebox:

Could Facebox be used for identifying a body/getting a body count from an image? Or would Classificationbox work better for something like that? Basically, I am not too concerned with facial recognition, but rather identifying if a person(s) is in the room?

Yes try Classificationbox. I believe @arsaboo has experimented with person detection. Also you could checkout the several threads discussing the use of Yolo for object detection. Checkout this repo also.

Great! Thanks for the recommendations!

1 Like

Hi, can you elaborate how you got https://github.com/RdeLange/robinvision this setup please? (newbie here)

What do you mean build the docker image? Do i copy all those file from your github ?

Thanks.

I would really like for this to be made into an addon or Hassio

I think in principle it could be a Hassio addon, but I’m not sure how great performance would be as these models typically require more RAM than a pi has

Yeah I don’t think it would run well on a pi, but on a NUC it should run fine.

@arsaboo has a NUC and is willing to test?

I’m willing to help

1 Like