Skip to main content

Diagram

How it works

  • Activity Monitor Lens running in Archetype platform
  • Real time camera analysis. To set up your own camera, follow the RTSP setup guide
  • Curated prompting. The model is prompted in a way that it tries to minimize hallucination, and to respond following a format that we can search after. It follows a 3 step process:
    1. Analyze exactly what it sees in the video
    2. Summarize observations related to the focus area
    3. Decide whether to send an alert using the word Alert at the beginning.
    "STOP. FOLLOW THIS EXACT FORMAT: Step 1: Write <scan> I see in this video: "
    "then list ALL detected objects, vehicles, people, animals, buildings, and their "
    "visual or behavioral attributes (colors, shapes, positions, actions). Then close "
    "with </scan>. Step 2: Write Search result: and analyze if the item or event being "
    "searched for is present in your scan. Step 3: If the searched-for item is not found, "
    "write: No alerts: short description of what was detected, max 15 words. "
    "If the searched-for item is present, it is VERY IMPORTANT THAT YOU WRITE THIS: "
    "**Alert**: short description of what was detected, max 15 words ONLY return one of the above. "
    "Do not describe anything else."
    
  • Response filtering. This format allows us to expect the trigger word “Alert” whenever what’s in focus is detected, so we watch for that trigger word to send alerts. That trigger word could be anything, but would need to match in both prompt and response filter.

Run the demos

Prerequisites

The instructions below assume you are following best practices and have downloaded this git repo into a parent directory at: ~/atai. If you have already installed the ATAI Python Library and cloned the cookbook repository, proceed directly to Quickstart.

Install Conda

wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
bash Anaconda3-2022.05-Linux-x86_64.sh
source ~/.bashrc

Setup dev environment

conda create -n dev_env python=3.10
conda activate dev_env

Install ATAI Python Library

git clone [email protected]:archetypeai/python-client.git
cd python-client
python -m pip install .

Clone the Cookbook Repository

git clone [email protected]:archetypeai/newton-demos.git

Configure RTSP Stream and Telegram Bot

  • RTSP Stream: Set up your camera’s RTSP stream using the RTSP Setup Guide
  • Telegram Bot: Create and configure your bot following the Bot Configuration Guide - you’ll need the bot token and chat ID

Run Demos

Demo 1: Command Line + Telegram

  • Open a terminal and activate the conda environment where python_client is installed
  • Navigate to telegram-alerts/terminal_bot
    $ cd telegram-alerts/terminal_bot
  • Open the file app.py
    • Add your bot token to BOT_TOKEN
    • Add your chat ID to CHAT_ID
  • In the terminal:
    • Run the following commands and follow the instructions:
    $ python app.py
    
When prompted, enter your API key, select rtsp/video and specify the focus area. The system will start monitoring and send notifications when alerts are triggered. Note that this script doesn’t terminate sessions automatically. To stop sessions, use either the console or visit: http://3.101.191.195:6011/lensapitools With this version, you can run multiple sessions simultaneously in different terminal windows.

Demo 2: Only Telegram demo

  • Open a terminal and activate the conda environment where python_client is installed.
  • Navigate to telegram-alerts/bot_only.
    $ cd telegram-alerts/bot_only
    $ pip install -r requirements.txt
  • Open the file app.py
    • Add your bot token to BOT_TOKEN
    • Add your chat ID to CHAT_ID
  • In the terminal:
    • Run the following commands:
    $ python app.py
    
  • When you run the script, you’ll receive a message in Telegram. Follow the instructions to configure your smart monitor.
Note: This version only supports running the script in one terminal window.