DeepStack AI Engine Documentation

repository·dev·Indexed 21 days ago

https://github.com/johnolafenwa/deepstack

A cross-platform AI engine providing high-performance computer vision APIs for face detection, recognition, object detection, and scene recognition. Designed for local and offline deployment on edge devices and private clouds, supporting Linux, macOS, Windows 10, NVIDIA Jetson, and Raspberry Pi/ARM64 with CPU and GPU acceleration.

Tokens
1.8K
Snippets
3
Records
9
Agent score
24%

What's inside DeepStack

  1. Overview of DeepStack AI Engine

    dev

    DeepStack is a cross-platform AI API engine designed to serve pre-built and custom models locally on edge devices or private clouds. It operates completely offline and supports various platforms including Linux (via Docker with CPU/NVIDIA GPU), macOS (via Docker), Windows 10 (native application), NVIDIA Jetson, and Raspberry Pi/ARM64 devices.

    Key capabilities include:

    • Face APIs: Detection, recognition, and matching.
    • Common Objects APIs: Detection for 80 common object classes.
    • Custom Models: Ability to train and deploy models for specific objects.
    • Image Enhance: 4X superresolution.
    • Scene Recognition: Identifying image scenes.
    • Security: Supports SSL and API Key authentication.
  2. DeepStack Integrations and Ecosystem

    dev

    DeepStack integrates with various platforms and tools for IoT, monitoring, and automation. Notable integrations include:

    • Home Assistant: Via HASS-DeepStack-Object, HASS-DeepStack-Face, and HASS-DeepStack-Scene addons.
    • Automation: node-red-contrib-deepstack for Node-RED and DeepStackAI Trigger (MQTT/Telegram support).
    • Video Management: Integrations with Blue Iris and AgenDVR.
    • Client Libraries: DeepStack-Python Helper for Python developers.
    • UI/Analytics: DeepStack-UI (Streamlit) and DeepStack-Analytics for exploring API data.
  3. Build DeepStack Docker Images from Source

    dev

    To build specific versions of DeepStack as Docker images, ensure you have installed the prerequisites (Golang, Docker, GIT, GIT LFS, Redis, Python3.7, and Powershell 7+).

    Follow these steps:

    1. Clone the repository: git clone https://github.com/johnolafenwa/DeepStack.git
    2. Enter the directory: cd DeepStack
    3. Fetch large files: git lfs pull
    4. Download binary dependencies (using Powershell): ./download_dependencies.ps1
    5. Build the desired version using the corresponding Dockerfile.
    # Build CPU Version
    sudo docker build -t deepquestai/deepstack:cpu . -f Dockerfile.cpu
    
    # Build GPU Version
    sudo docker build -t deepquestai/deepstack:gpu . -f Dockerfile.gpu
    
    # Build Jetson Version
    sudo docker build -t deepquestai/deepstack:jetpack . -f Dockerfile.gpu-jetpack
  4. Run DeepStack Locally without Docker

    dev

    You can run DeepStack locally by setting up a Python virtual environment and building the Go server.

    Prerequisites:

    • Python 3.7
    • Go (Golang)
    • Redis Server
    • Powershell 7+

    Steps:

    1. Create and activate a virtual environment: python3.7 -m venv venv and source venv/bin/activate.
    2. Install requirements: pip3 install -r requirements.txt.
    3. Install PyTorch (CPU or GPU version) using the specific URLs provided in the documentation.
    4. Use Powershell (pwsh) to run the setup scripts (.\setup_docker_cpu.ps1 or .\setup_docker_gpu.ps1).
    5. Navigate to the server directory and build the server with go build.
    6. Enable specific APIs by setting environment variables (e.g., VISION_DETECTION = "True").
    7. Run the server with .\server.

    DeepStack runs on port 5000 by default.

    # Example: Enabling Vision Detection and Running (in Powershell)
    $env:VISION_DETECTION = "True"
    $env:VISION_FACE = "True"
    $env:VISION_SCENE = "True"
    .\server
  5. Configure DeepStack via Environment Variables and CLI Flags

    dev

    DeepStack can be configured using environment variables or command-line flags during startup.

    Core Configuration

    • VISION-FACE: Enable/disable face detection (Boolean).
    • VISION-DETECTION: Enable/disable object detection (Boolean).
    • VISION-SCENE: Enable/disable scene recognition (Boolean).
    • VISION-ENHANCE: Enable/disable image super-resolution (Boolean).
    • API-KEY: Secure endpoints with an API key.
    • ADMIN-KEY: Secure admin-only endpoints (backup, restore, model management).
    • PORT: The port the server runs on (default: 5000).
    • TIMEOUT: Request timeout in seconds (default: 300.0).
    • THREADCOUNT: Number of threads to use for each endpoint (default: 5).
    • MODE: Performance mode (e.g., Medium).
    • DATA_DIR: Path to the datastore (default: /datastore).
    • TEMP_PATH: Path for temporary file storage (default: /deeptemp/).
  6. DeepStack API Environment Variables

    dev

    When running the DeepStack server manually, you can enable specific API modules by setting the following environment variables to "True":

    • VISION_DETECTION: Enables object detection APIs.
    • VISION_FACE: Enables face detection, recognition, and matching APIs.
    • VISION_SCENE: Enables scene recognition APIs.
    $env:VISION_DETECTION = "True"
    $env:VISION_FACE = "True"
    $env:VISION_SCENE = "True"
  7. Backup and Restore DeepStack Data

    dev

    DeepStack allows for full system backups and restorations, including vision models and the face embedding database. These endpoints require an ADMIN-KEY.

    • Backup: POST /v1/backup Generates a .backup zip file containing all vision models and the faceembedding.db file. The response is a downloadable file stream.
    • Restore: POST /v1/restore Accepts a .backup file via multipart/form-data to restore the system state.
  8. Manage Custom Vision Models

    dev

    Administrators can register, list, and delete custom vision models via the API. These endpoints require an ADMIN-KEY.

    • Register Model: POST /v1/vision/addmodel Requires model (file), config (file), and name (form field).
    • List Models: GET /v1/vision/listmodels Returns a list of registered models, their update dates, and sizes.
    • Delete Model: POST /v1/vision/deletemodel Requires name (form field).
    • Use Custom Model: POST /v1/vision/custom/{model_name} Once registered, you can call this endpoint to perform detection using that specific model.
  9. DeepStack Vision API Endpoints

    dev

    DeepStack provides a RESTful API for various computer vision tasks. Most endpoints require an image uploaded via multipart/form-data. Some endpoints require an API-KEY or ADMIN-KEY for authentication.

    Vision Endpoints

    • Scene Recognition: POST /v1/vision/scene - Identifies the scene in an image.
    • Object Detection: POST /v1/vision/detection - Detects objects. Supports a min_confidence parameter.
    • Image Enhancement: POST /v1/vision/enhance - Performs super-resolution on an image.
    • Custom Models: POST /v1/vision/custom/{model_name} - Uses a custom trained detection model.

    Face Endpoints

    • Face Detection: POST /v1/vision/face/ - Detects faces in an image. Supports min_confidence.
    • Face Recognition: POST /v1/vision/face/recognize - Recognizes a face in an image. Supports min_confidence.
    • Face Registration: POST /v1/vision/face/register - Registers a new user with one or more images. Requires userid and multiple image files.
    • Face Matching: POST /v1/vision/face/match - Matches faces in provided images against the database.
    • Face Management: POST /v1/vision/face/delete (removes a user) and GET /v1/vision/face/list (lists all registered user IDs).