NickM-27 / swatch

Color detection in images to capture presense of known objects.
Apache License 2.0
68 stars 4 forks source link

[Support]: Container will not start #62

Open janstadt opened 11 months ago

janstadt commented 11 months ago

Describe the problem you are having

Im running unraid and using the official unraid appstore version of swatch with all the default docker configs (i've placed a config.yaml in the correct location i believe. container maps to /config/config.yaml).

Version

crzynik/swatch:latest

Swatch config file

# REQUIRED: Define a list of objects that are expected to be seen. These can be specific
# to one camera or common between many / all cameras
objects:
  # REQUIRED: Name of the object
  trash_can:
    # REQUIRED: the list of color variants that this object can be detected as. Useful for
    # different lighting conditions
    color_variants:
      # REQUIRED: the name of the color variant
      default:
        # REQUIRED: the lower R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_lower: 70, 70, 0
        # REQUIRED: the upper R, G, B values that are considered a potential match for the
        # color variant of the object.
        color_upper: 110, 100, 50
        # OPTIONAL: the time range for when this color variant is allowed
        # NOTE: make sure that /etc/localtime is passed to the container so it has valid time
        time_range:
          # OPTIONAL: Color variant is valid if current time is > this 24H time (Default: shown below).
          after: "00:00"
          # OPTIONAL: Color variant is valid if current time is < this 24H time (Default: shown below).
          before: "24:00"
    # OPTIONAL: the min area of the bounding box around groups of matching R, G, B pixels
    # considered a true positive. This is not recommended to be set as a super small amount
    # could be a false positive. (Default: shown below)
    min_area: 1000
    # OPTIONAL: the max area of the bounding box around groups of pixels with R, G, B
    # values within the bounds to be considered a true positive (Default: shown below).
    max_area: 100000
    # OPTIONAL: the min ratio of width/height of bounding box for valid object detection (default: shown below).
    min_ratio: 0
     # OPTIONAL: the max ratio of width/height of bounding box for valid object detection (default: shown below).
    max_ratio: 24000000
# REQUIRED: Define list of cameras that will be used for color detection.
cameras:
  # REQUIRED: Name of the camera
  porch:
    # OPTIONAL: Frequency in seconds to run detection on the camera.
    # a value of 0 disables auto detection (Default: shown below).
    auto_detect: 0
    # OPTIONAL: Configure the url and retention of snapshots. (Default: Shown Below)
    snapshot_config:
        # OPTIONAL: but highly recommended, setting the default url for a snapshot to be
        # processed by this camera. This is required for auto detection (Default: none).
        #url: "http://ip.ad.dr.ess/jpg"
        # OPTIONAL: Whether or not to draw bounding boxes for confirmed objects in the snapshots (Default: shown below).
        bounding_box: true
        # OPTIONAL: Whether or not to save a clean png of the snapshot along with the annotated jpg (Default: shown below).
        clean_snapshot: true
        # OPTIONAL: Whether or not to save the snapshots of confirmed detections (Default: shown below).
        save_detections: true
        # OPTIONAL: Whether or not to save the snapshots of missed detections (Default: shown below).
        save_misses: false
        # OPTIONAL: Variations of snapshots to keep. Options are all, mask, crop (Default: shown below).
        mode: "all"
        # OPTIONAL: Number of days of snapshots to keep (Default: shown below).
        retain_days: 7
    # REQUIRED: Zones are cropped areas where the object can be expected to be.
    # This makes searching / matches for efficient and more predictable than searching
    # the entire image.
    zones:
      # REQUIRED: Name of the zone.
      driveway_entry:
        # REQUIRED: Coordinates to crop the zone by.
        # NOTE: The order of the coordinates are: x, y, x+w, y+h starting in the top left corner as 0, 0.
        coordinates: 225, 540, 350, 620
        # REQUIRED: List of objects that may be in this zone. These correspond to
        # the objects list defined previously and are matched by name.
        objects:

Relevant log output

ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.11/site-packages/werkzeug/urls.py)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/swatch/swatch/__main__.py", line 6, in <module>
    from swatch.app import SwatchApp
  File "/opt/swatch/swatch/app.py", line 16, in <module>
    from swatch.http import create_app
  File "/opt/swatch/swatch/http.py", line 10, in <module>
    from flask import (
  File "/usr/local/lib/python3.11/site-packages/flask/__init__.py", line 7, in <module>
    from .app import Flask as Flask
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 27, in <module>
    from . import cli
  File "/usr/local/lib/python3.11/site-packages/flask/cli.py", line 17, in <module>
    from .helpers import get_debug_flag
  File "/usr/local/lib/python3.11/site-packages/flask/helpers.py", line 14, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.11/site-packages/werkzeug/urls.py)

Any other information that may be helpful

I've also tried configuring this with docker-compose using the following but with the same issues. The config locations are a bit different but still map to the correct locations in the container.

  swatch:
    container_name: swatch
    image: crzynik/swatch
    #depends_on:
    #  - nginx-proxy-manager
    privileged: true
    network_mode: swatch_network
    restart: always
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
    ports:
      - "4500:4500"
      - "4501:4501"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${ROOT}/config/swatch/config/config.yaml:/config/config.yaml:ro #also tried just mapping the directories
      - ${ROOT}/config/swatch/media:/media
janstadt commented 11 months ago

Would be really great to get a docker-compose example in your documentation. I am running HA in a container and cant rely on HA Addons so i typically stand up my own containers and go from there.

funkybunch commented 11 months ago

I'm having this issue with the latest release as well. I was able to at least get it working standalone in Docker by rolling back to the 3.1.0 tag with the following docker-compose entry.

version: '3'
services:
  swatch:
    container_name: swatch
    image: crzynik/swatch:3.1.0-2717ec6
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - swatch:/config/:ro
      - swatch_media:/media/
    ports:
      - "4500:4500"
    restart: unless-stopped

volumes:
  swatch:
  swatch_media:
ginkel commented 4 months ago

According to https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr this is caused by a dependency conflict