Face and person detection with Deepstack - local and free!

Thanks very much @mayker . I am the CEO of DeepQuest AI, the company building DeepStack.

Updates will be made to DeepStack soon with more APIs and Admin UI added.

5 Likes

Dusted down an old Mac with Ubuntu and running deepstack on it, getting sub second responses :slight_smile: I am curious what other hardware people are using to run Deepstack?

1 Like

This is cool! Great work trying that out.

DeepStack works best on Ubuntu because Docker is well optimized for Linux systems, allowing the full potentials of DeepStack to manifest.

For much higher performance, we also provide a version of DeepStack that leverages NVIDIA GPUs to provide 10X and more performance on both Linux and Windows systems. Installation guide for this can be found in the documentations linked below.

Python Documentation: https://deepstackpython.readthedocs.io

NodeJS Documentation: https://deepstacknodejs.readthedocs.io

C# Documentation: https://deepstackcsharp.readthedocs.io

Mine is running on a 10 year old desktop . Seem to work great.

1 Like

Right - more clearer then…which cameras actually work well with HomeAssistant? Do any of them support live streaming?

I have all my camera connected through zoneminder, I have minder event server turned on , it sends a MQTT message to HASS when it see motion in the ZM zones. I use the motion detection to trigger the image_processing.scan service

Doesn’t that defy the point of occupancy detection? You’re having to move to scan the picture. This sounds like it works as a very complicated PIR, unless you just want it for face detection?

I want it to sense if someone is in the room or not live so i can do proper accurate occupancy stuff.

1 Like

I don’t use it for occupancy detection , all my camera are outside. When I am not at home I want to know what/who is in the yard or drive way or how many people are at the front door.

2 Likes

@TheDanShepherd cameras on the HA front end update 1 fps, so not exactly a live stream, but usable. I believe there are improvements in the pipeline. Personally I am using $10 USB webcams

2 Likes

Would it be possible (noob here), to make a short video of how you got it up and running on the Linux on your Mac?
Just the deepstack part and the link to HA?

Thanks really cool feature!!

1 Like

Just my two cents, but the person needs to get into the room somehow, so the initial motion could trigger taking a snapshot of the room. Which is then analyzed for occupancy and stored in a sensor. Or if you want to just use a live stream, just have it analyze the feed in real time.

1 Like

@Yoinkz theres many ways you could go about it, I actually replaced the whole OSX with Ubuntu, but equally you could run in Virtualbox. Then, I just followed the Deepstack docs, simples :slight_smile:

1 Like

Makes sense.

I think for my room occupany stuff it would be best to have perhaps two cameras. One in the corner of the room looking over everything and one along the desk checking to see if anyone is sat down. The one in the corner would probably miss someone sat at the desk as its going to be almost behind a large chair.

I guess a standard PIR to capture initial movement for turning lights on quickly would complete the package.

It’s either than or a mixture of an IR beam and motion sensors.

1 Like

Yeah I went the snapshot/motion route because I wasn’t comfortable with a live stream analysis, even though all my cameras are local

1 Like

Okay Rob,

Will give it a try :slight_smile:

1 Like

@TheDanShepherd I’ve been using this component ‘realtime’ for occupancy detection - rather than trigger on motion - and it works rather well. i have the scan set for 10s and it gives me a pretty solid overview of how many people are where in the house. I use it to help keep lights on when people have been sat still passed the trigger point of my PIR automations!
the resultant problem is one of performance. my basement server (@robmarkcole it’s an old but decent i3 2130 with 16g ram) spent until recently most of its waking life idling, the occasional plex transcode taking me to around 10%. Now, with three cameras running oject/person model only (no face component being used) it’s at 45%-60% all the time. I would like to employ this component on more cameras/in more rooms, but worry that it’ll peg my server and affect other services it provides.
Also worth noting is that my homes energy usage has noticably risen as a result of this heavier server activity. only 25p a day more, but still…
Fantastic component all in all. Great work Robin!

3 Likes

that’s the reason why don’t you run the image_processing.scan service every 10 seconds. it overloads the server and may cause it to crash. Only scan when it is necessary. This is what I have for my kitchen and it works fine for me…

##########################################################
# Automation
##########################################################
automation:
  - alias: 'Start scan when Scan Kitchen is on'
    initial_state: on
    trigger:
      platform: state
      entity_id: input_boolean.scan_kitchen
      from: 'off'
      to: 'on'
    action:
      - service: image_processing.scan
        entity_id:
          - image_processing.kitchen_person_count
      - delay:
          seconds: 1
      - service: input_boolean.turn_off
        entity_id: input_boolean.scan_kitchen
      - service: timer.start
        entity_id: timer.scan_kitchen

  - alias: 'Kitchen activity detected start scan'
    initial_state: on
    trigger:
      platform: state
      entity_id:
        - binary_sensor.kitchen_motion_sensor
        - binary_sensor.kitchen_door_motion_sensor
        - binary_sensor.cam_3_field_detection
        - binary_sensor.kitchen_window
        - binary_sensor.back_door
    condition:
      - condition: state
        entity_id: binary_sensor.kitchen_occupancy
        state: 'off'
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.scan_kitchen

  # When timer is done, start scan
  - alias: 'Scan Kitchen Timer Finish'
    initial_state: 'on'
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.scan_kitchen
    condition:
      - condition: state
        entity_id: binary_sensor.kitchen_occupancy
        state: 'on'
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.scan_kitchen






##########################################################
# Timer
##########################################################
timer:
  scan_kitchen:
    name: 'Scan Kitchen Timer'
    duration: '00:00:30'






##########################################################
# Input Boolean
##########################################################
input_boolean:
  scan_kitchen:
    name: Scan Kitchen
    initial: off






##########################################################
# Binary Sensor
##########################################################
binary_sensor:
  - platform: template
    sensors:
      kitchen_occupancy:
        friendly_name: "Kitchen Occupancy"
        device_class: occupancy
        value_template: >-
          {{ states('image_processing.kitchen_person_count')|float > 0 }}





##########################################################
# Customize
##########################################################
homeassistant:
  customize:
    image_processing.kitchen_person_count:
      friendly_name: 'Kitchen Person Count'
9 Likes

an interesting approach @masterkenobi - so basically it waits for any initial motion to ‘die down’ before checking against the deepstack model. nice.
is the timer set at 30s for any particular reason?

Basically when activity is detected (motion and door open or close), it will start scan if no one was detected prior to that. If someone is detected, then it will continue to scan for every 30 seconds until no one is detected.

No particular reason why 30 seconds. You can adjust it until you feel it is balanced between performance and results.

2 Likes

I’ve installed the container for both facial and object detection. While i can get the object detections working everything i’ve tried for the facial detection component doesn’t return any results. I’ve run the service "name": "Superman", "file_path": "/config/www/superman.jpg" and then run the scan service. The component neither detects a person in the picture nor the identified face. Again no issue with he object detection. Don’t really see any errors in my log. Any ideas?

1 Like