Skip to content
/ ZM_ML Public

A Machine Learning client/server library designed specifically for ZoneMinder object/face/ALPR detection. Powered by OpenCV DNN module (other frameworks coming!), can be TPU/GPU accelerated.

License

Notifications You must be signed in to change notification settings

rabsym/ZM_ML

Repository files navigation

Support

Join Slackdrawing

Please support ZoneMinder if you can!

If you use software from the ZoneMinder organization please consider sponsoring ZoneMinder. ZoneMinder has been free with a paid support option and paid bounties but, it has come to the communities attention that the main/only dev of ZM needs help with bringing cash flow in. If you have the means, please consider sponsoring ZoneMinder, Thanks!

ZoneMinder Machine Learning Library (ZM ML)

Try the x86_64 GPU/TPU accelerated Server docker image! docker.io/baudneo/zm_ml:server-full

NOTE

This software is currently in alpha stage, expect issues. That said, it is fairly fast. YMMV.

This is a project aiming to update how ZoneMinder Object Detection works. A server and client are supplied to allow for easy integration with ZoneMinder.

All the server does is run ML models on supplied images and return its results.

The client is an asynchronous (mostly) script installed on the ZoneMinder machine, which grabs and sends images to a ZM ML server for inference and then processes the results to annotate images, create animations and send notifications, if configured to do so.

Thanks

-> This project is based on the work of @pliablepixels. <-

Prerequisites for Server and Client

  • ZoneMinder 1.37.5+ (EventStartCommand is REQUIRED)
  • Python 3.8+ (3.9 recommended) [3.10+ DOES NOT SUPPORT TPU ATM]
  • Python packages required by the install script
    • psutil
    • request
    • tqdm
    • distro
  • OpenCV (Contrib) 4.2.0+ (4.7.0+ recommended) with Python3 bindings.
    • OpenCV is not installed by default due to possible GPU acceleration by user compiled OpenCV.

Notes:

  1. EventStartCommand/EventEndCommand is what runs the object detection script. Before, SHM was polled every <X> seconds to see if a new event had been triggered.

Installation

Docker

Client

The client does not have a docker image.

Server

See the Wiki Docker page for pre requisites, tags and instructions.

Manual Install

See the Wiki for Manual Installation instructions.

Bootstrap Manual Install (WIP)

See the Wiki for Bootstrap instructions.

Server info

  1. Based on FastAPI (With all the Pydantic goodness!)
  2. OpenCV DNN for CPU/GPU
  3. OpenALPR local binary supported (Must compile OpenALPR with CUDA for GPU support)
  4. Cloud ALPR integrations. [See notes]
  5. pycoral (tflite) for TPU support.
  6. DLib based face-recognition (GPU Recommended)
  7. Run locally on ZoneMinder machine or deploy to a remote machine.
  8. Docker images! Docker Hub

Server - Supported Hardware

⚠️ NOTE: If you do a manual install and want GPU accelration, you will need to compiel OpenCV, DLib and OpenALPR with CUDA support!

  1. AMD GPU's (ROCm) are NOT supported, blame AMD.
  2. Intel ARC/iGPU's are CURRENTLY NOT supported. (this may change as I am working on OpenVINO support)
  3. NVidia GPUs are supported. (CUDA)
    • GPU must be Compute Capability 5.3+
    • See here for a list of GPUs and their Compute Capability
  4. Coral.ai Google edgeTPU Accelerator (USB is confirmed, M.2/PCIe needs testing)
  5. CPU

NVIDIA GPU Acceleration

See the Wiki Manual Installation Server GPU page for pre requisites and instructions.

Coral EdgeTPU Acceleration

See the Wiki Manual Installation Server TPU page for pre requisites and instructions.

Server - Notes

  1. pycoral recently released wheels for Python3.10 See here
    • NOTE: It is recommended to use python 3.8 or 3.9 if you want to use TPU acceleration.

Client Info

The client uses the new ZoneMinder EventStartCommand/EventEndCommand option. This means ZM kicks off the ML chain instead of the ML chain scanning SHM looking for an event, more efficient!

The client grabs images, sends the images to mlapi servers, filters detected responses, post processes images and sends notifications. All the heavy computation of ML models is done by the server!

Client Pre-requisites

  • Client MUST be installed on same host as ZM server. Multi-server ZM installs (untested) will require a client install on each server.
  • OpenCV is REQUIRED for image processing, you can use opencv-contrib-python if you do not need GPU acceleration.
  • libgeos-dev : system package (used for the Shapely python module; Polygons)
  • gifsicle : system package (used to optimize GIFs; makes file size much smaller)

WebSocket Server (WIP)

The websocket server is a legacy supporting server for zmNinja. Its sole purpose is to obtain tokens to send push notifications to zmNinja clients (Android/iOS) and retain some legacy functions in zmNinja.


Environment Variables

Check back later for a list of environment variables and their explanation.

About

A Machine Learning client/server library designed specifically for ZoneMinder object/face/ALPR detection. Powered by OpenCV DNN module (other frameworks coming!), can be TPU/GPU accelerated.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published