Face and person detection with Deepstack - local and free!

Basically we just need to port the events from facebox if anyone wants to make a PR :grin:

I have set a scan interval of 8s (I kept for month 5s with no issues) but I don’t have any value published to the sensor.

not sure how to call the service through developer tools: should I pass only the camera entity or other parameters?

@mspinolo depends on which method you want to use (Automation, Node-Red, manual service call).

Basically, depending on the method, just call the image_processing.scan service with the entity_id of your image processing object (deepstack).

So, for instance, I have defined my deepstack object like this…

# Image Processing / recognition
image_processing:
  - platform: deepstack_face
    ip_address: 192.168.1.146
    port: 8087 
    timeout: 5
    detect_only: False
    scan_interval: 10000
    source:
      - entity_id: camera.front_door_cam
        name: facial

I’m using Node-Red to call the service when I detect motion from my camera.

You could do the same in an automation or manually.
Just call the “image_processing.scan” service with the “entity_id” of your image scanning object.
In my example the entitiy_id of my object is “image_processing.facial” since “facial” is the friendly name I gave the object.

I just released v0.4 of deepstack face which includes a image_processing.detect_face event that is fired for each recognised face. This event can be used to trigger automations.

CC @glilly

1 Like

hi @glilly,

thank you very much for your help!
So I dug a bit more into it and here are my findings:

  • if I run manually the service from the developer panel it works fine and update the sensor
    t
  • although I set properly scan_interval I believe even waiting 24h doesn’t lead to sensor update
image_processing:
  - platform: deepstack_object
    ip_address: XXX.XXX.X.X
    port: 5000
    scan_interval: 5

this makes me think I am doing something wrong with scan_interval (but again I used it for month…I couldn’t find any breaking changes about it) or there is a bug?

@robmarkcole - Just a heads up, I tried the latest version 0.4 and it stopped making calls to the deepstack server. I had to revert back to 0.3 and was working again after that. No config change on my end for HA.

That gives me zero information to help debug the situation

I was viewing the docker logs, no calls were being made to it and no responses. No errors in HA either. Not sure what information you require, happy to provide if you can direct me where I can view anything since neither HA or Deepstack docker provided me with anything.

Is this deepstack-face? Please check your HA logs in debug mode, perhaps installation of the dependency failed.

I am using deepstack-face v0.4 and it has been working perfectly fine for me for the last day

1 Like

I was able to finally figure this out and am posting here in case someone else is struggling with this, I had to change from trigger.event.data.object to trigger.event.data.name to get the name of what was detected to come thru in my notifications

 action:
  - data_template:
        title: 'Object Detected'
        message: '{{ trigger.event.data.name }} with confidence {{ trigger.event.data.confidence }}'
1 Like

@robmarkcole You’re Awesome!! Thanks for the quick update.
I’ll implement it in a couple of days… heavy workload right now so can’t play with the things that I’d rather be working on. :crazy_face: I’ll send feedback on my experience also. :wink:

1 Like

Hi @mspinolo
What is it that you’re trying to do exactly?
Are you wanting your image processing / detection to run every 5 seconds (as you have it now)?
If so, what are you doing to detect a change in the state of the deepstack_object?
How are you checking it to see if the status changes when you’re running different scan intervals?

I was having an issue early on when I was figuring this out and I had a scan interval set (10 seconds) and I found this was difficult for me to use reliably to determine if it was working. I would walk out to the camera and it would detect my face but by the time I came back and checked the status, it was back to “unknown” so I was struggling with that initially.

I now have a Node-Red flow that runs the image_processing.scan in a service node. The flow waits for the service to complete then I check the results to see if any faces were detected and if so, were any recognized. The key is to trigger or detect if the image_scan found something and use that to fire an automation or event handler.

Robin just updated the face recognition code to include event outputs for recognized faces. I will be testing that in a couple of days.

I’m so close I can taste it! I’m still having issues reliably getting results though, and have posted more info in this bug: https://github.com/robmarkcole/HASS-Deepstack-object/issues/124.

TLDR: HASS doesn’t update regularly when i call scan service. I Can see see in the logs it does process events after being called, but the latest image doesn’t always update, and is worse for one deepstack_object instance than the other. Has anyone else seen this? I’ve disabled ROI zones, and that does not make a difference.

Also thanks Rob for your work here. No pressure at all, this is not mission critical.

Hey Gilly,

Can you please share your node-red flow ?

Thanks !

@Auto101 sure… here ya go.

Some of the logic in it you shouldn’t need now because Robin updated the script to include event firing for recognized faces. I was parsing the results to get the names of who was recognized here. I haven’t updated to the latest rev from Robin yet, so it’s still there.

The timestamp nodes are just there so I could monitor how long the entire flow was taking with the facial recognition etc…

Hi Greg,

So what I am trying to do, which is how all this was working since a couple of weeks ago, is to make the integration to update the image process every 5 seconds.

If I start Home Assistant I get the image processing sensor never updating


As you can see in this image.

If instead I fire the service from the developer panel it updates once (when I fire it) but then it does not anymore.
t

See example above.

In general, as I am targeting person as object, I would expect sensor to display “0” and not “unknown”.

It looks like, for some reason, scan_interval Is ignored, if it makes sense

Do anyone know why we are using the noavx image tag? I noticed that it has not been updated in a while. How is it different from latest tag?
I’ve been running both of them side by side for some time now. Both seem to work fine, but latest is usually 20-30% faster.

EDIT: I think I figured it out. noavx is for older systems, so I should probably switch to using latest then.

@mspinolo none of the deepstack integrations use scan_interval anymore. I just fixed the deepstack face docs to indicate this.

Ah, that was my issue with deepstack face v0.4, scan interval wasn’t working, hence no logs. Didn’t realise that was the change made to make it similar to deepstack object.

My bad @robmarkcole.

1 Like