Neural Network Human Presence Detection

Oh man this is brilliant, I got it working with HA + automation and is working like a charm !!
I really apreciate your help and support !! I have learned a lot with all this staff …

1 Like

You’re totally welcome, glad that you were able to get it all working!

on which hardware do you run it?

motionEye:
Debian 9 + motionEye running as Parallels VM on iMac using pass through for the iMac iSight Camera

Home Assistance:
HassOS Docker hypervisor running on Raspberry Pi 3 B+

Neural_Security_System:
Ubuntu 16.04 runing as VirtualBox 6 VM on Windows 10 Laptop

trying to follow your instruction, got a problem.
" This project assumes you have installed the toolkit as a regular user, and not root. When you get to the step to run sudo ./install_GUI.sh , run it without sudo instead."

So I am trying to install but I do not have permission
the following location are read-only
/home/myname/intel

EDIT I did
sudo chmod -R 777 /home/myname/intel

What type of error do you get?

Looks cool. Just curious, from a security standpoint, can it detect a “fully masked burglar” maybe like the movies with black clothes and black masks and what not.

I mean how does it recognize humans?

It can do text recognition - so you’d just need to look for the word SWAG on his bag.

1 Like

Hi, that error I fixed, I can’t make it work even with the hack for ubuntu 18.04

The “rules” for what it detects are not actually well-defined. It’s essentially a neural network that has been trained on thousands of pictures of people, and it has “learned” what a person looks like.

That’s why it will detect just a hand as “person”, or just a head, or just a leg. It recognizes the “concept” of a person.

Yeah, unfortunately I think that’s why they officially don’t support 18.04.

Alright, another update to the app. I have added signal handling to the app. I was sick of rebooting the VM to find out that it caused the program to exit in the middle of an inference, causing me to have to unplug and replug the neural compute stick in to get it working again.

So, it now will handle Ctrl-C (sigint) and a linux system’s sigterm (what it sends programs when rebooting or shutting down). It catches those signals, and then gracefully exits the program while not in the middle of an inference.

Also, thought I’d share what my script looks like that runs it on startup, and how to set it up to run as a service.

Here’s my script:
~/neural-security.sh

#!/bin/bash

echo "$(tail -n 100 /home/nicholas/log_neural.log)" > /home/nicholas/log_neural.log

exec &>> /home/nicholas/log_neural.log

source /home/nicholas/intel/computer_vision_sdk/bin/setupvars.sh

./neural_security_system -i http://192.168.1.52:8081 -m ./models/tiny_yolov3/FP16/frozen_tiny_yolo_v3.xml -d MYRIAD -u username -p password -tp cameras/front_door/humans -no_image -mh tcp://192.168.1.51:1883 -cr 150 -ct 80 -t 0.3

Then make it executable:

sudo chmod +x neural-security.sh

Then create the service file:

sudo nano /etc/systemd/system/neural-network.service

Put this in the file:

[Unit]

Description=auto start stream

After=multi-user.target

[Service]

Type=simple

ExecStart=/home/nicholas/neural_security.sh

User=nicholas

WorkingDirectory=/home/nicholas/security_system

Restart=on-failure

[Install]

WantedBy=multi-user.target

Make sure the paths and username are correct (your Ubuntu user).

Then you can enable the service to run on system startup:

sudo systemctl enable neural-network

You can also stop, start, or disable it from starting on boot:

sudo systemctl stop neural-network
sudo systemctl start neural-network
sudo systemctl disable neural-network

Very nice! Any chance you will do a setup video to show how you set the whole thing up?

Thanks for sharing this. I’m playing with it for a few days and it works nice. Are there downloadable models only with persons class? I don’t want to detect cows, bears and zebras only persons.

You say that now, but you’ll sing a different tune next time a zebra breaks in and eats all your left over pizza.

1 Like

:slight_smile: those f****** pizza eating zebras. Then i need persons and zebras.

For YOLOv3, while you can retrain the network to only recognize one class of objects, it takes quite a bit of work. You’d have to use tensorflow to retrain the model, and use your own massive dataset of people images.

The code I wrote uses YOLOv3, but ignores detections for anything except the person class for publishing to MQTT. That’s what most people do so as to not retrain the network from scratch (can take quite awhile).

If you went down another route to use a network other than YOLOv3 with this app, then the app would have to be rewritten. Every network expects the image to conform to some input rules, and the way it formats the output is different as well.

Ok. Thanks. Not gonna do that. :slight_smile: This works fine. Also one more question. Can i use rtsp stream or mmjpeg camera is needed?

Yeah, and YOLOv3 on only one class performs just as fast as with 80. You might get improved accuracy, but that’s it.

As far as RTSP streams, I haven’t been able to get it to work. OpenCV is used to pull in the video, and I believe it works with TCP RTSP streams (but not UDP ones). However, my camera is a Raspberry Pi running raspivid through VLC like here: https://chriscarey.com/blog/2017/04/30/achieving-high-frame-rate-with-a-raspberry-pi-camera-system/

Unfortunately, that results in a UDP RTSP stream, which OpenCV has a problem with. It might be able to work with your setup though.

1 Like

I successfully installed neural_security_system in Ubuntu 18.04. And everything works when i run it with

./neural_security_system -i http://10.210.1.8:8888/videostream.cgi -m ./models/tiny_yolov3/FP32/frozen_tiny_yolov3_model.xml -d CPU -t 0.6 -tp cameras/front_door/humans -u test -p test  -mh tcp://localhost:1883 -cr 50

But if i add -no_image then it doesn’t work. Everything starts ok but i don’t get any messages in mosquitto.

./neural_security_system -i http://10.210.1.8:8888/videostream.cgi -m ./models/tiny_yolov3/FP32/frozen_tiny_yolov3_model.xml -d CPU -t 0.6 -tp cameras/front_door/humans -no_image -u test -p test  -mh tcp://localhost:1883 -cr 50
	API version ............ 1.5
	Build .................. lnx_20181004
	Description ....... MKLDNNPlugin
[ INFO ] Loading network files
[ INFO ] Batch size is forced to  1.
[ INFO ] Checking that the inputs are as the demo expects
[ INFO ] Checking that the outputs are as the demo expects
[ INFO ] Loading model to the plugin
[ INFO ] Start inference