Add AI Models database schema and management UI #4499
Draft
+918
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements database schema and admin UI for managing AI object detection models, datasets, and classes in ZoneMinder. Separates concerns between AI datasets (COCO, ImageNet), model implementations (YOLOv8, SSD), and object classes, with per-monitor detection settings.
Database Schema
Five interconnected tables in
db/AI_Models.sql:Pre-populated COCO 2017 dataset with 80 object classes in
db/coco_dataset.sql. Default detection settings enabled for person (60% threshold) and vehicles (50% threshold).UI Implementation
Three new tabs in Options menu following existing Storage/Servers patterns:
Modal editors for CRUD operations, backend action handlers in
web/includes/actions/, JavaScript consolidated in existingoptions.js.Architecture
Foreign keys enforce referential integrity.
INSERT IGNOREfor idempotency. Uses subqueries instead of hardcoded IDs for resilience.All UI components follow ZoneMinder conventions:
canEdit('System')permission checks,makeLink()clickable rows, Bootstrap styling, CSRF protection, helper functions (dbQuery(),validHtmlStr(),getFormChanges()).Original prompt
Overview
REVISION: Updated architecture with proper separation between AI Models, Datasets, and Object Classes
Add comprehensive database schema and user interfaces for managing AI object detection in ZoneMinder. This includes proper separation between AI model implementations, datasets (like COCO), object classes, detection settings per monitor, and detection results.
Database Schema Changes
Create new SQL file
db/AI_Models.sqlwith the following tables:1. AI_Datasets Table
Stores AI datasets (COCO, ImageNet, custom datasets):
2. AI_Models Table
Stores AI model implementations (YOLOv8, SSD, etc.):
3. AI_Object_Classes Table
Stores object classes from datasets:
4. AI_Detection_Settings Table
Stores detection settings per monitor and object class (MonitorId NULL = default):
5. AI_Detections Table
Stores actual detection results:
COCO Dataset Pre-population
Create
db/coco_dataset.sql: