Face and person detection with Deepstack - local and free!

I did, but the weird thing is it worked for a while (and i was aiming to improve the speed of it using GPU)

any other ideas - it seems to be timing out. Any way to increase the logging information?

When I go to run Deepstack after install I get this error:

root@Docker:~# docker run -e VISION-SCENE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"proc\\\" to rootfs \\\"/var/lib/docker/vfs/dir/edcc8f3822992ea249e0c03890d56031f1e7499716d699a0513065c0756cb4b5\\\" at \\\"/proc\\\" caused \\\"permission denied\\\"\"": unknown.

@paul.etheridge does inference time improve noticeably if you use USB3?
@jaburges your best bet is the Deepstack forums
@Dayve67 you could try sudo

1 Like

@jaburges Did you ever come right? Im also having the same issue. My previous install of DeepStack worked fine on the same machine.

No return from ```
curl -X POST -F image=@development/test-image3.jpg ‘http://localhost:5000/v1/vision/detection

oh thank god - i’m not the only one lol

no - started looking at tensorflow (but no dockerimage, and creating my own custom whl is a pain in the arse as there are some issues in the code)

so back to deepstack for now.
any idea if there is a way to get more verbose logging?

@robmarkcole I am getting average 990ms on USB2 and now 710ms on USB3.

1 Like

ok further investigation, deepstack is working but locally.
copying the test-image over to the mounted volume then running the curl query from inside the docker using localhost does return a response.

running it from the host, pointing to the IP:port does not. So its definitely a communication thing

Think i’ve cracked it :slight_smile:
@robmarkcole it seems that the response when nothing is detected isn’t being inferred as 0, but instead unknown.
image.jpg gets various info back in JSON (chairs etc)
image1.jpg gets the below response
{"success":true,"predictions":[]}

If I save the image from image.jpg as image1.jpg (basically same file, different picture) and re-run the curl query I get a full set of responses, so its not communication or permissions.

1 Like

I’ve rarely experienced images which yielded no predictions at all - is it a photo at night or something like that?

actually think i finally managed to narrow it down to the scan_interval

once that is reached, image_processing seems to send all entities at once and crash the GPU docker, or something within the docker as the log doesnt show that HA cant see it.
P.S. sorry for all the edits, been tracking this down all afternoon

testing a much longer scan_interval to see if that fixes the issue

HA is not suitable if you want a high frequency/low latency image processing tool. Recommend you checkout the Frigate project of @blakeblackshear to meet that requirement.

Oh no, this is what i’m looking for - but the issue i’ve been having, with the GPU deepstack docker is it has stopped responding (but couldn’t figure out why).

It seems to be down to the 'scan_interval. Whenever that number is reached (and setting it much higher seems to have validated this) HA sends [u]all the entities[/u] in the image_processing` entity list to deepstack at once. This log entry seems to confirm this;

Not passing an entity ID to a service to target all entities is deprecated. Update your call to image_processing.scan to be instead: entity_id: all

This all at once scan seems to crash the GPU docker, and then the image_processing no longer works but the docker shows as online so no logs in HA, just no responses from HA or via curl manually.

I can’t disabled scan_interval as the default is 10 seconds. I’d be happy if I could have an infinite number there, as i’m scanning on demand (when motion is detected).

EDIT: added topic in deepstack forum

You can set a long scan interval see https://www.home-assistant.io/components/image_processing/#scan_interval-and-optimising-resources

@Dayve67, Your localstorage:/datastore should be replaced with the real local path. For example /docker/deepstack:/datastore.

I also recommend configuring docker do be run as non-root user: https://docs.docker.com/install/linux/linux-postinstall/.

1 Like

How can I make sure that the camera is updated when my sensor is triggered, instead of the image_processing uses a picture that potentially is 8 seconds old? I haven’t set anything manually on my generic camera, so I guess the picture just updates every 10th seconds?

I’m using the generic platform for my cameras.
I have an automation that calls the image_processing when a sensor is triggered.

@Yoinkz, image_processing.scan should scan the still_image_url from the camera entity. If you try browsing that url and the snapshot is recent, then you know deepstack will scan the up to date image when triggered.

If you are using the picture-entity lovelace card the thumb is updated every 10 second but that is not the image being scanned.

@rs443 Hmm, maybe it was just some hickups on my Network. It actually seems to take the picture immediately when the rule is triggered.

But lets say that my motion sensor triggers and I want the DeepStack to scan every 30 second, while the Motion Sensor is ‘On’. It will stay ‘On’ for 5 minutes unless activity of course.
Right now I have one rule that scans for Cars, so if someone drives up - activates the sensor because of the car, then my rule with the person scan is already triggered and I won’t find out if a person gets out of the car.

Does it make sense - and is that somehow doable?

thanks, got this running on a gen 8 i5 nuc.

Deepstack person detection installed inside Ubuntu VM under Proxmox enviro. Seperate VM running Hassio (be nice). Using HA hikvision binary sensor (motion) component to call the scan service.

In any case I have not yet maxed out spare CPU availability to the VM and most detections are done under a second. Good enough for me!

Not sure if its the architecture (or how i’ve set up vm) but I could only get the noavx version to work anyone got ideas? Is this worth digging into deeper? Any noticeable difference in response times?

@Yoinkz, you could repeat the scan several times with a delay between scans when motion triggers the automation, like this:

action:
  - service: image_processing.scan
    entity_id: image_processing.mycamera
  - delay: 00:00:30
  - service: image_processing.scan
    entity_id: image_processing.mycamera
  - delay: 00:00:30
  - service: image_processing.scan
    entity_id: image_processing.mycamera
  - delay: 00:00:30
  - service: image_processing.scan
    entity_id: image_processing.mycamera

So did some more testing if you are running this in a VM, make sure you pass through a fairly new CPU so the with avx version works. Processing times dropped for me around 40/50%.

Sorry for the wall of text below, but is it possible to implement a zoning feature. I read above that you could use proxy cameras but I was thinking in the first instance allowing someone to optionally configure just one of x/y min/max. This would allow for the bounding box outside of the region to be green (dont care) with those crossing the boundary drawn in red (care).

Whilst the image_processing.file_saved event considers when the object == the target and higher then confidence levels. Maybe another event to capture when all of these are true and the x/y boundary is triggered. (ie lowest line trigger would be prediction[‘y_min’] < y_limit).

So, in the end we have images saved for all scan events that are of high enough confidence of this being the target but if someone configures an x/y then an additional event will fire saving a boundary cross event.

At a minimum if image_processing.object_detected event returned x/y dimensions people could write their own automations to handle boundary limit detection.