Metadata-Version: 2.1
Name: pyzm
Version: 2.2.0
Summary: ZoneMinder API, Logger and other base utilities for python programmers
Home-page: https://github.com/pliablepixels/pyzm
Author: Pliable Pixels
Author-email: info@zoneminder.com
License: GPL
Project-URL: Documentation, https://pyzmv2.readthedocs.io/en/latest/
Project-URL: Source, https://github.com/pliablepixels/pyzm
Project-URL: Bug Tracker, https://github.com/pliablepixels/pyzm/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.18.4
Requires-Dist: pydantic>=2.0.0
Requires-Dist: dateparser>=1.1.0
Requires-Dist: mysql-connector-python>=8.0.16
Requires-Dist: python-dotenv
Provides-Extra: full
Requires-Dist: numpy>=1.13.3; extra == "full"
Requires-Dist: Pillow; extra == "full"
Requires-Dist: onnx>=1.12.0; extra == "full"
Requires-Dist: Shapely>=1.7.0; extra == "full"
Requires-Dist: portalocker>=2.3.0; extra == "full"
Requires-Dist: fastapi>=0.100; extra == "full"
Requires-Dist: uvicorn>=0.20; extra == "full"
Requires-Dist: python-multipart>=0.0.5; extra == "full"
Requires-Dist: PyJWT>=2.0; extra == "full"
Requires-Dist: PyYAML>=5.0; extra == "full"
Requires-Dist: ultralytics>=8.3; extra == "full"
Requires-Dist: streamlit>=1.41; extra == "full"
Requires-Dist: streamlit-drawable-canvas>=0.9; extra == "full"
Requires-Dist: st-clickable-images>=0.0.3; extra == "full"
Provides-Extra: ml
Requires-Dist: numpy>=1.13.3; extra == "ml"
Requires-Dist: Pillow; extra == "ml"
Requires-Dist: onnx>=1.12.0; extra == "ml"
Requires-Dist: Shapely>=1.7.0; extra == "ml"
Requires-Dist: portalocker>=2.3.0; extra == "ml"
Provides-Extra: serve
Requires-Dist: numpy>=1.13.3; extra == "serve"
Requires-Dist: Pillow; extra == "serve"
Requires-Dist: onnx>=1.12.0; extra == "serve"
Requires-Dist: Shapely>=1.7.0; extra == "serve"
Requires-Dist: portalocker>=2.3.0; extra == "serve"
Requires-Dist: fastapi>=0.100; extra == "serve"
Requires-Dist: uvicorn>=0.20; extra == "serve"
Requires-Dist: python-multipart>=0.0.5; extra == "serve"
Requires-Dist: PyJWT>=2.0; extra == "serve"
Requires-Dist: PyYAML>=5.0; extra == "serve"
Provides-Extra: train
Requires-Dist: numpy>=1.13.3; extra == "train"
Requires-Dist: Pillow; extra == "train"
Requires-Dist: onnx>=1.12.0; extra == "train"
Requires-Dist: Shapely>=1.7.0; extra == "train"
Requires-Dist: portalocker>=2.3.0; extra == "train"
Requires-Dist: ultralytics>=8.3; extra == "train"
Requires-Dist: streamlit>=1.41; extra == "train"
Requires-Dist: streamlit-drawable-canvas>=0.9; extra == "train"
Requires-Dist: st-clickable-images>=0.0.3; extra == "train"
Requires-Dist: PyYAML>=5.0; extra == "train"

<img src="logo/pyzm.png" width="200"/>

What
=====
pyzmv2 is a rewrite of pyzm.

It's a pythonic wrapper that integrates with ZM and also operates as a standalone ML library. Key features:
- ZM API
- ZM Event Server
- ZM Logger
- ZM Memory
- Machine Learning Modules (with our without ZM)

Installation
=============
See the [installation guide](https://pyzmv2.readthedocs.io/en/latest/guide/installation.html) on ReadTheDocs.

Documentation & Examples
=========================
Latest documentation is available <a href='https://pyzmv2.readthedocs.io/en/latest/'>here</a>. The documentation includes a full example.

Features
=========
- API auth using tokens or legacy (manages refresh logins automatically)
- Monitors
- Events with filters
- States
- Configs
- EventNotification callbacks
- Mapped Memory access
- Direct access to ML algorithms
- Remote ML detection server (`pyzm.serve`) — run models on a GPU box, detect from anywhere
- [Amazon Rekognition support](https://medium.com/@michael-ludvig/aws-rekognition-support-for-zoneminder-object-detection-40b71f926a80) for object detection

Training UI
============

pyzm includes a Streamlit-based UI for fine-tuning YOLO models on your own data:

```bash
/opt/zoneminder/venv/bin/python -m streamlit run pyzm/train/app.py -- --base-path /var/lib/zmeventnotification/models
```

The `--base-path` flag points to your ZoneMinder models directory (defaults to `/var/lib/zmeventnotification/models`). Projects are stored in `~/.pyzm/training/`.

Testing
========

pyzm has three test tiers:

**Unit / integration tests** (no hardware required):
```bash
pip install pytest
python -m pytest tests/ -m "not e2e and not zm_e2e" -v
```

**ML end-to-end tests** (require real ML models on disk):
```bash
# Requires models in /var/lib/zmeventnotification/models/
# and the test image at tests/test_ml_e2e/bird.jpg (included in repo)
python -m pytest tests/test_ml_e2e/ -v

# Skip the slower remote-serve tests:
python -m pytest tests/test_ml_e2e/ -v -m "not serve"
```

**ZoneMinder end-to-end tests** (require a live ZM server):

One-time setup:
```bash
sudo /opt/zoneminder/venv/bin/pip install pytest
cp tests/.env.zm_e2e.sample .env.zm_e2e   # edit with your ZM server details
```

```bash
# Readonly tests (auth, monitors, events, zones, frames, detection):
sudo -u www-data /opt/zoneminder/venv/bin/python -m pytest tests/test_zm_e2e/ -v -p no:cacheprovider

# Include write tests (event notes, stop/start/restart, DB tagging):
sudo -u www-data ZM_E2E_WRITE=1 /opt/zoneminder/venv/bin/python -m pytest tests/test_zm_e2e/ -v -p no:cacheprovider
```

ZM E2E tests auto-skip when `.env.zm_e2e` is missing, so `pytest tests/` is always safe.

Developer Notes (for myself)
=============================
To make a release:
```
./scripts/make_release.sh
```

To skip PyPI upload (e.g. package already published):
```
./scripts/make_release.sh --skip-pypi
```

To test docs:
```
cd docs/
make html && python -m http.server -d _build/html
```

To test a CHANGELOG:
```
# __version__ in pyzm/__init__.py should be updated
# replace v2.0.3 with whatever future version
GITHUB_TOKEN=$(gh auth token) git-cliff --tag "v2.0.3"
```

Limitations
============
* Requires Python 3.10+



