Face and person detection with Deepstack - local and free!

In the UI, you should delete the original erroneous faces.

Hey, thanks for reply. I already ā€œsolvedā€ my problem same day when I asked for help, by deleting deepstack persistent data, reinstalling deepstack and reinstalling HACS integrations (face and object). I believe that problem was solved by deleting deepstack persistent data actually (i.e. docker-compose-deepstack/data/faceembedding.db) and that re-installation of HACS integrations and docker container wasnā€™t needed at all, but cannot tell this for sure.

Anyway, I donā€™t get you. Where in the UI I can find anything related with remembered faces? At least, I cannot find it. The only two entities I have related with deepstack are: image_processing.deepstack_object_lenovo and image_processing.deepstack_face_lenovo, both related with camera on Lenovo tablet, and the only two services are image_processing.scan and deepstack_face.teach_face. I cannot find any place in UI where would be possible to see and manipulate with remembered faces.

Thx.

I meant in the deepstack UI, but in hindsight i was actually thinking of double take, which has a UI and can add or remove faces through that.

Lol, I didnā€™t knew there is a Deepstack UI at all :rofl:
I didnā€™t knew even for Deepstack before few weeks and I discovered it via Home Assistant.
Just installed UI container, things are clear now, thanks.

Iā€™m feeling a little ā€œdumbā€ for not getting the hang out of it, so please excuse me if the question seems stupid or repeated. ( I did search the entire thread with ā€œsearchā€ and I donā€™t think Iā€™ve found any mention of it)

I am trying to launch a simple automation that should work around this logic condition: ā€œIF Deepstack detects a Car in the image, THEN do the followingā€¦ā€

The idea is to use DeepStack to detect a car in the driveway and only then pass the image to a PlateReader to read the Plate Number and proceed with the automation.

Now, I can successfully call the image_processing.deepstack service via automation (Iā€™m using an Hikvision camera with Line Crossing capabilities) but I canā€™t get to the part where I can extract the ā€œa car has been detectedā€ from the flow and use it as an argument for the next step.

Currently my ā€œimage_processing.deepstack_object_porta_garageā€ state reports correctly this payload:

targets:
  - target: car
    confidence: 60
targets_found: []
summary: {}
last_target_detection: 2022-12-25_21-07-34-520308
all_objects:
  - tv: 26.803
  - cat: 27.97
  - teddy bear: 28.901
  - teddy bear: 29.182
  - teddy bear: 29.819
  - teddy bear: 36.741
  - car: 52.207
save_file_folder: /config/ia/camera-garage
save_file_format: png
save_timestamped_file: true
always_save_latest_file: true
unit_of_measurement: targets
friendly_name: deepstack_object_porta_garage

and Iā€™ve tried writing an automation like this:

if:
  - condition: state
    entity_id: image_processing.deepstack_object_porta_garage
    attribute: summary
    state: car
then:
  - service: image_processing.scan
    data: {}
    target:
      entity_id: image_processing.platerecognizer_porta_garage

But of course it never validates. Iā€™m pretty sure I must be committing a majestic error with the ā€œstate: carā€ part of it, but I canā€™t figure out the proper way to do it.

I tried using a template, like:

"{{ is_state('image_processing.deepstack_object_porta_garage.Summary', 'car') }}"

But still I had no luck with it.
I was hoping someone could be kind enough to point me in the right direction of what kind of syntax to useā€¦

Hi

Not looked at this topic for a while, but Iā€™m fairly sure your object detection score needs to exceed your set confidence score to fire off an object detected event.

In your case, object- car 52.207 needs to exceed confidence=60

Thank you Nigel, I realize I was an idiot because I posted the deepstack state when the car wasnā€™t in position.

I did again the test, and the confidence level is goo enough for detection (when the car is in the right spot, of course) so now the output is as following:

targets:
  - target: car
    confidence: 60
targets_found:
  - car: 79.277
summary:
  car: 1
last_target_detection: 2022-12-25_21-02-09-279321
all_objects:
  - stop sign: 11.191
  - teddy bear: 26.127
  - car: 79.277
save_file_folder: /config/ia/camera-garage
save_file_format: png
save_timestamped_file: true
always_save_latest_file: true
unit_of_measurement: targets
friendly_name: deepstack_object_porta_garage

Still, I canā€™t get a ā€œCondition Passā€ on the Automation. I tired also using ā€œā€ and ā€˜ā€™ to wrap the word car but to no avail.

I discovered that this condition is correctly validated, but Iā€™m feeling unsure about using it because it is not specific:

condition: state
entity_id: image_processing.deepstack_object_porta_garage
state: "1"

I created two sensor for my deepstack response
this is the one for ā€˜personā€™

      - name: "Person detected"
        state: > 
                        {% set pd = state_attr('image_processing.deepstack_outdoor_live_cam_onvif','summary') %} 
                        {% for x in [pd][0] %}
                        {% if x == "person" %}
                        Person: {{ pd[x] }}
                        {% endif %}
                        {% endfor %}

Guys, I would have two questions:

  1. Does Deepstack gives poor performance regarding face recognition for you? In my case, everything seems to be ok with object detection, but in case of face recognition, there are so many mistakes. For example: In this first period when Iā€™m playing with HA/Deepstack and exploring possibilities and performance, I trained it with photos of my two sons, my wife and my self, 20 photos per person. All photos are cropped, so only head and barely little space around the head is on the photo. However, there is a wrong person recognized very often. Ok, I can understand that in case of my sons - they are young, 8 and 13, and they are similar, but what I cannot understand is that when I scan e.g. photo of my son, one of these Deepstack was trained with, Deepstack will recognize it as my another son (wrong). How this could be possible, I mean it is one of the photos used for training and Deepstack should already remembered exact that photo. Iā€™m comparing this with CompreFace, where mistakes are also happens from time to time, but never in case if I scan some of photos used for training. In case of photo used for training, confidence is always 100% on CompreFace. Another thing: In my case, Deepstack very rare gives me ā€œunknownā€ recognition. No matter if I scan the photo of some unknown person, in most of the cases Deepstack will (false) recognize it as some of 4 of us, with some low level of confidence. This question is more as ā€œwhat is your experience, and could something be done to raise accuracyā€?
  2. Second question would be much shorter: Is it development dead maybe? I mean, I can see on github, last version was released almost 1 year ago. Donā€™t take me wrong, Iā€™m not asking for ETA here, just curious.

Thx.

Thank you @vingerha! This is really usefull. May I ask to share a little bit more on how did you configure this sensor in the config file?

I suppose this is something like:

  - platform: template
    sensors:
      deepstack_object:
        friendly_name: "car detected"
        value_template: "{% set pd = state_attr('image_processing.deepstack_camera.porta_garage','summary') %} 
                        {% for x in [pd][0] %}
                        {% if x == "car" %}
                        Person: {{ pd[x] }}
                        {% endif %}
                        {% endfor %}"

but Iā€™m not sure itā€™s coded correctly.

(edit: indeed, I tried and of course itā€™s not correct. sigh.)

So here is what I have spread out over multiple yaml)

image_processing:
  - platform: deepstack_object
    ip_address: 192.168.1.20
    port: 8085
    scan_interval: 10000
    save_file_folder: /config/www/
    save_file_format: png
    save_timestamped_file: False
    always_save_latest_file: True
    scale: 0.75
    roi_x_min: 0.2
    roi_x_max: 0.99
    roi_y_min: 0.01
    roi_y_max: 0.99
    targets:
      - target: person
        confidence: 60
      - target: vehicle
        confidence: 60
      - target: car
        confidence: 40
      - target: cat
        confidence: 40
      - target: dog
        confidence: 40
    source:
      - entity_id: camera.tapofront_mainstream
        name: deepstack_outdoor_live_cam_onvif        
        
camera:
  - platform: local_file
    name: deepstack_outdoor_still_onvif
    file_path: /config/www/deepstack_outdoor_live_cam_onvif_latest.png    

template:
  - sensor:
      - name: "Person detected"
        state: > 
                        {% set pd = state_attr('image_processing.deepstack_outdoor_live_cam_onvif','summary') %} 
                        {% for x in [pd][0] %}
                        {% if x == "person" %}
                        Person: {{ pd[x] }}
                        {% endif %}
                        {% endfor %}
      
      - name: "Object detected"
        state: > 
                        {% set pd = state_attr('image_processing.deepstack_outdoor_live_cam_onvif','summary') %} 
                        {%- for x in [pd][0] %}
                        {{x}}:{{pd[x]}}
                        {%- endfor %}

Hi, IĀ“m quite new on this.
IĀ“m having troubles when using the service " Image processing: Scan face"
When it executed some times it donĀ“t take a new image to use it, it use the latest photo that it is in the folder:

 save_file_folder: /media/deepstack/snapshots

Do some one have the same issue and know how to fix it?

My config in the configuration.yaml is:

image_processing:
  - platform: deepstack_face
    ip_address: localhost
    port: 83
    timeout: 10
    detect_only: False
    save_file_folder: /media/deepstack/snapshots
    save_timestamped_file: false
    save_faces: True
    save_faces_folder: /media/deepstack/faces
    show_boxes: false
    source:
      - entity_id: camera.timbre
        name: face

hello,

What would be the easiest way to fetch the name of the detection if confidence is > than 70% ???
Am looking for an automation, that will give me the name and then use this for a welcome msg.

This is an old post, but image_processing.detect_face events is not running for me either.
Any update on this ?

@robmarkcole Hi Rob, I just now noticed that you archived your repo and you probably have very good reasons for this but it is a shame and would like to thank you for the work done.
Could you posisbly shed a bit of light on this so that I/we understand what options there are?
For now, I have forked yours so not affected (right now)

13 Likes

Hi all, iā€™m trying to apply object detection with Deepstack on my Jetson Xavier NX.
Can someone please share a Docker Compose example i can use with my Xavier ?
Thanks,

Have I missed something here? I recognise that the HACS integration has been ā€˜archivedā€™ but I have not disabled it but it is also not working.

If I go into developer tools - services, the image_processing option for deepstack is no longer there.

So HACS is stopping it from loading, but I canā€™t figure out how to ignore this?

Same here, any reason? I really appreciated your work and have been using this with great success.

Hello,

i have problem with Deepstack give me red icon and the error is:

{
	"success": false,
	"error": "Face endpoints not activated",
	"duration": 0
}

any help ?

thank you