neilenns / node-deepstackai-trigger

Detects motion using Deepstack AI and calls registered triggers based on trigger rules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deepstack stuck on Analyzing when triggered

alustig opened this issue · comments

Hi everyone, I am trying to get this working on my system. It consists of Deepstack GUI being run in a docker container on a windows machine at (192.168.1.14:5000) with an NVIDIA graphics card via this docker run command:

docker run -d --name deepstack \
-e VISION-DETECTION=True \
-v localstorage:/datastore \
-p 80:5000 \
deepquestai/deepstack:gpu-2020.12

I could never get deepstack working on my Unraid server because it doesn't have a graphics card (its a Dell R740xd) and the noavx version requires an API key but the webpage to get an API key is currently broken.

On my Unraid server I am running node-deepstackai-trigger by using the files below. What I want to do it have an MQTT message triggered to my Home Assistant instance (192.168.1.125) when a person or dog is seen on the Backyard camera. Currently I am placing a screenshot of a dog into the /mnt/user/deepstack/aiimages folder and that file is named "Backyard - 1-18-2021 9.35.57pm.jpg"

My problem is Deepstack seems to hang or get stuck on the Analyzing phase because nothing ever gets returned. I've checked the MQTT topic on my home assistant instance and nothing changes. Here is the log output from node-deepstack-ai after waiting 10 mins:

2021-01-18T21:31:57-05:00 [Main] ****************************************,
2021-01-18T21:31:57-05:00 [Main] Starting up version 5.6.1,
2021-01-18T21:31:57-05:00 [Main] Timezone offset is 300,
2021-01-18T21:31:57-05:00 [Main] Current time is Mon Jan 18 2021 21:31:57 GMT-0500 (Eastern Standard Time),
2021-01-18T21:31:57-05:00 [Settings] Loaded settings from /run/secrets/settings,
2021-01-18T21:31:57-05:00 [MQTT] Connected to MQTT server http://192.168.1.125:1883,
2021-01-18T21:31:57-05:00 [Local storage] Creating local storage folders in /node-deepstackai-trigger.,
2021-01-18T21:31:57-05:00 [Local storage] Enabling background purge every 60 minutes for files older than 30 minutes.,
2021-01-18T21:31:57-05:00 [Local storage] Running purge,
2021-01-18T21:31:57-05:00 [Main] Annotated image generation enabled.,
2021-01-18T21:31:57-05:00 [Main] Web server enabled.,
2021-01-18T21:31:57-05:00 [Triggers] Loaded configuration from /run/secrets/triggers,
2021-01-18T21:31:57-05:00 [Triggers] Loaded configuration for Backyard,
2021-01-18T21:31:57-05:00 [Trigger manager] There are 0 images waiting in /aiinput for Backyard.,
2021-01-18T21:31:57-05:00 [Pushbullet] Pushbullet is disabled via settings.,
2021-01-18T21:31:57-05:00 [Pushover] Pushover is disabled via settings.,
2021-01-18T21:31:57-05:00 [Telegram] Telegram is disabled via settings.,
2021-01-18T21:31:57-05:00 [Mqtt router] Subscribing to node-deepstackai-trigger/statistics/reset.,
2021-01-18T21:31:57-05:00 [Web server] Listening at http://localhost:4242,
2021-01-18T21:31:57-05:00 [Mqtt router] Subscribing to node-deepstackai-trigger/statistics/trigger/reset.,
2021-01-18T21:31:57-05:00 [Local storage] Purge complete,
2021-01-18T21:31:57-05:00 [Mqtt router] Subscribing to node-deepstackai-trigger/motion.,
2021-01-18T21:31:57-05:00 [Trigger Backyard] Listening for new images in /aiinput/Backyard*.jpg,
2021-01-18T21:31:57-05:00 [Main] Watching for changes to /run/secrets/settings,
2021-01-18T21:31:57-05:00 [Main] Watching for changes to /run/secrets/triggers,
2021-01-18T21:31:57-05:00 [Main] ****************************************,
2021-01-18T21:31:57-05:00 [Main] Up and running!,
2021-01-18T21:36:15-05:00 [Trigger Backyard] /aiinput/Backyard - 1-18-2021 9.35.57pm.jpg: Analyzing,

And here is the log output from the Deepstack container:

/v1/vision/detection,
---------------------------------------,
---------------------------------------,
�,
p,
---------------------------------------,
v1/restore,

My Deepstack instance is activated on the Windows PC and I have verified I can ping it and access the url from other machines on my network. Anyone have any guidance? thank you!

Deepstack Activated Screenshot

docker-compose.yml:

version: "3.8"
services:
  trigger:
    volumes:
      # Change d:/myfolder/myimages to point to the folder that will have the images
      # to analyze. Only change the local path that is before the :/aiinput portion.
      # Don't change the :/aiinput part. For example, if you are on Windows and your
      # images are stored locally in d:/blueiris/capturedImages your final line should
      # look like this:
      # d:/blueIris/capturedImages:/aiinput
      - /mnt/user/deepstack/aiimages:/aiinput

    environment:
      # Change this to match the timezone the images are produced in,
      # Typically this will be the timezone of the machine running
      # the Docker container. For a list of valid timezone values
      # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
      # The value to use is in the "TZ database name" column.
      - TZ=America/New_York

    ports:
      # This port is used by the local web server when annotated images are enabled.
      # If you change the port used by the local web server in the settings.json file
      # this also has to change to match.
      - 4242:4242

    # ------------------------------------------------------------------------
    # Don't change anything below this line unless you know what you are doing
    secrets:
      - triggers
      - settings
      - secrets
    image: danecreekphotography/node-deepstackai-trigger:latest
    container_name: node-deepstackai-trigger 
    restart: always
    volumes:
      - /mnt/user/deepstack/anotated:/node-deepstackai-trigger
      - /mnt/user/deepstack/aiimages:/aiinput

volumes:
  localstorage:

secrets:
  settings:
    # This should point to the location of the settings.json configuration file
    file: ./settings.json
  triggers:
    # This should point to the location of the triggers.json configuration file
    file: ./triggers.json
  secrets:
    # This should point to the location of the secrets.json configuration file
    file: ./secrets.json

triggers.json:

{
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/triggerConfiguration.schema.json",
  "triggers": [
    {
      "name": "Backyard",
      "watchPattern": "/aiinput/Backyard*.jpg",
      "enabled": true,
      "threshold": {
        "minimum": 50,
        "maximum": 100
      },
      "handlers": {
        "webRequest": {
          "triggerUris": ["http://localhost:81/admin?trigger&camera=Backyard&memo={{formattedPredictions}}"]
        },
        "mqtt": {
          "messages": [{ "topic": "aimotion/triggers/backyard" }]
        },
        "pushover": {
          "userKeys": ["1"]
        },
        "telegram": {
          "chatIds": [1],
          "annotateImage": true
        }
      },
      "watchObjects": ["person", "dog"]
    }
  ]
}

settings.json:

{
  // Leave this line alone. It enables Intellisense when editing this file in Visual Studio Code.
  "$schema": "https://raw.githubusercontent.com/danecreekphotography/node-deepstackai-trigger/main/src/schemas/settings.schema.json",

  // This is the default uri for Deepstack when deploying using the docker-compose.yaml file
  // provided in this sampleConfiguration folder. If you have another deployment of Deepstack
  // running elsewhere change this setting to point to the correction location.
  "deepstackUri": "http://192.168.1.14:5000/",

  // Set this to true to enable annotated images for use in trigger handlers.
  // There is a performance penalty to using this, leave it off unless
  // you really want to see the annotated images.
  "enableAnnotations": true,

  // Set this to true to enable the internal web server for remote access
  // to processed and annotated images.
  "enableWebServer": false,

  // Enables verbose logging. Useful when setting up the system to ensure
  // everything is running correctly.
  "verbose": true,

  // Set this to true if your images are stored in a remote folder that's
  // mounted as a network share and then mapped to the Docker image.
"awaitWriteFinish": false,

  // Provides the configuration details for your MQTT server. To enable
  // mqtt set the uri, username (if required), password (if required),
  // and set enabled to true.
  "mqtt": {
    "uri": "http://192.168.1.125:1883",
    "username": "{{mqttUsername}}",
    "password": "{{mqttPassword}}",
    "enabled": true
  },

  // Provides the configuration details for Telegram bot messages.
  // Set the botToken and enabled to true to use Telegram.
  "telegram": {
    "botToken": "insert bot token here",
    "enabled": false
  },

  // Provides the configuration details for Pushbullet notifications.
  // Set the accessToken and enabled to true to use Pushbullet.
  "pushbullet": {
    "accessToken": "access token here",
    "enabled": false
  },

  // Provides the configuration details for Pushover notifications.
  // Set the apiKey, userKey, and enabled to true to use Pushover.
  "pushover": {
    "apiKey": "api key here",
    "userKey": "user key here",
    "enabled": false
  }
}

Unfortunately this is going to be an issue with the Deepstack server. This was the experience people would get when the server wasn't activated with an API key, but as you mention they've done away with that. I suggest posting in the Deepstack forum (https://forum.deepstack.cc/) to see if they have any ideas what could be causing this. I'm honestly surprised nothing useful showed in the logs for the deepstack image :(

I just noticed you're running the Deepstack service outside of the docker-compose.yaml for the overall system. It's possible it's a networking issue between the trigger container and the PC hosting the service. That's the reason why I have them both spun up in the same docker-compose file: it gets rid of all of that nonsense and possible issues.

Why not just keep the compose file provided in the sample directory and adjust it to point to the deepquestai/deepstack:gpu-2020.12 image instead of latest? Sure that means the trigger system won't be running on unraid, but at least you can eliminate issues with the Deepstack image and confirm they can talk to each other.

Unfortunately this is going to be an issue with the Deepstack server. This was the experience people would get when the server wasn't activated with an API key, but as you mention they've done away with that. I suggest posting in the Deepstack forum (https://forum.deepstack.cc/) to see if they have any ideas what could be causing this. I'm honestly surprised nothing useful showed in the logs for the deepstack image :(

Got it working by doing this. I'm running Deepstack and the node-deepstckai-trigger both on the Windows 10 PC.