blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.02k stars 1.74k forks source link

[Config Support]: How to config and store Custom Model with Frigate Home Assistant add on #7819

Closed lahayeg closed 1 year ago

lahayeg commented 1 year ago

Describe the problem you are having

Hello, I would like to use a custom model EfficientDet-Lite3x* with my Coral usb. I'm running Frigate on the Hassio addon. I configured my frigate.yml file like this:

model:
  path: /frigate/efficientdet_lite3x_640_ptq_edgetpu.tflite
  labelmap_path: /frigate/coco_labels.txt
  width: 640
  height: 640

Where to create my frigate folder?

Version

0.12.0-DA3E197

Frigate config file

# yaml-language-server: $schema=http://ccab4aaf-frigate:5000/api/config/schema.json
mqtt:
  host: x.x.x.x
  port: 1883
  topic_prefix: frigate
  client_id: ***
  user: ***
  password: ***
  stats_interval: 60

detectors:
    coral:
      type: edgetpu
      device: usb

model:
  path: /frigate/efficientdet_lite3x_640_ptq_edgetpu.tflite
  labelmap_path: /frigate/coco_labels.txt
  width: 640
  height: 640

birdseye:
    enabled: False
rtmp:
    enabled: False
live:
  height: 240
  quality: 8

objects:
  # Optional: list of objects to track from labelmap.txt (default: shown below)
  track:
  - person
  - bicycle
  - car
  - motorcycle
  - bird
  - cat
  - dog

snapshots:
  enabled: True

record:
  enabled: true
  events:
    pre_capture: 1
    post_capture: 2
    retain:
      default: 5

cameras:
  parking:
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://***:***@x.x.x.x:554/h264Preview_01_sub #https://www.ispyconnect.com/camera/reolink
          roles:
            - detect
      #      - record
        - path: rtsp://***:***@x.x.x.x:554/h264Preview_01_sub 
          roles:
            - record
    detect:
      width: 640
      height: 360
      fps: 4
    motion:
      mask:
        - 0,360,208,360,203,0,0,0
  jardin:
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://***:***@x.x.x.x:554/h264Preview_01_sub 
          roles:
            - detect
      #      - record
        - path: rtsp://***:***@x.x.x.x:554/h264Preview_01_main
          roles:
           - record
    detect:
      width: 1536
      height: 576
      fps: 4
    motion:
      mask:
        - 569,282,604,576,0,576,0,315
        - 1536,576,1536,346,1276,338,1107,576

Relevant log output

-

Frigate stats

No response

Operating system

HassOS

Install method

HassOS Addon

Coral version

USB

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

Where to create my frigate folder?

You can't, that doesn't work. It must have a root of /config or /media/frigste as those are the only folders frigate has access to

lahayeg commented 1 year ago

Hi @NickM-27 I should store files here /root/config/frigate And in my config set path: /config/frigate/efficientdet_lite3x_640_ptq_edgetpu.tflite ?

NickM-27 commented 1 year ago

I believe that would work

lahayeg commented 1 year ago

The path seems as worked but now, frigate is not detecting Coral

2023-09-15 12:35:34.188271032  [2023-09-15 14:35:34] peewee_migrate                 INFO    : Starting migrations
2023-09-15 12:35:34.246673697  [2023-09-15 14:35:34] peewee_migrate                 INFO    : There is nothing to migrate
2023-09-15 12:35:34.291185886  2023/09/15 14:35:34 [error] 133#133: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001/stats", host: "ccab4aaf-frigate:5000"
2023-09-15 12:35:34.291525552  172.30.32.1 - - [15/Sep/2023:14:35:34 +0200] "GET /api/stats HTTP/1.1" 502 157 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-15 12:35:34.334878821  [2023-09-15 14:35:34] frigate.app                    INFO    : Output process started: 303
2023-09-15 12:35:34.341928993  [2023-09-15 14:35:34] detector.coral                 INFO    : Starting detection process: 301
2023-09-15 12:35:34.343461245  [2023-09-15 14:35:34] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-09-15 12:35:34.360140633  [2023-09-15 14:35:34] frigate.app                    INFO    : Camera processor started for parking: 306
2023-09-15 12:35:34.397952501  [2023-09-15 14:35:34] frigate.app                    INFO    : Camera processor started for jardin: 310
2023-09-15 12:35:34.419884551  [2023-09-15 14:35:34] frigate.app                    INFO    : Capture process started for parking: 312
2023-09-15 12:35:34.454893969  [2023-09-15 14:35:34] frigate.app                    INFO    : Capture process started for jardin: 314
2023-09-15 12:35:35.016033218  [INFO] Starting go2rtc healthcheck service...
2023-09-15 12:35:40.463255816  Process detector:coral:
2023-09-15 12:35:40.470000971  [2023-09-15 14:35:40] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2023-09-15 12:35:40.478366563  Traceback (most recent call last):
2023-09-15 12:35:40.478451915    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2023-09-15 12:35:40.478456415      delegate = Delegate(library, options)
2023-09-15 12:35:40.478460822    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2023-09-15 12:35:40.478532951      raise ValueError(capture.message)
2023-09-15 12:35:40.478678765  ValueError
2023-09-15 12:35:40.478683136  
2023-09-15 12:35:40.478686895  During handling of the above exception, another exception occurred:
2023-09-15 12:35:40.478688636  
2023-09-15 12:35:40.478691191  Traceback (most recent call last):
2023-09-15 12:35:40.478694747    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-09-15 12:35:40.478696802      self.run()
2023-09-15 12:35:40.478700228    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-09-15 12:35:40.478707876      self._target(*self._args, **self._kwargs)
2023-09-15 12:35:40.479482317    File "/opt/frigate/frigate/object_detection.py", line 98, in run_detector
2023-09-15 12:35:40.479496428      object_detector = LocalObjectDetector(detector_config=detector_config)
2023-09-15 12:35:40.479595095    File "/opt/frigate/frigate/object_detection.py", line 52, in __init__
2023-09-15 12:35:40.479645983      self.detect_api = create_detector(detector_config)
2023-09-15 12:35:40.479651076    File "/opt/frigate/frigate/detectors/__init__.py", line 24, in create_detector
2023-09-15 12:35:40.479653817      return api(detector_config)
2023-09-15 12:35:40.479657557    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 37, in __init__
2023-09-15 12:35:40.479660909      edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2023-09-15 12:35:40.479664817    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2023-09-15 12:35:40.479668020      raise ValueError('Failed to load delegate from {}\n{}'.format(
2023-09-15 12:35:40.479671002  ValueError: Failed to load delegate from libedgetpu.so.1.0
2023-09-15 12:35:40.479672687  
2023-09-15 12:35:43.474297922  172.30.32.1 - - [15/Sep/2023:14:35:43 +0200] "GET /api/stats HTTP/1.1" 200 2372 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-15 12:35:52.166767546  172.30.32.1 - - [15/Sep/2023:14:35:52 +0200] "GET /api/stats HTTP/1.1" 200 2374 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-15 12:35:53.755746273  [2023-09-15 14:35:53] frigate.comms.mqtt             ERROR   : Unable to publish to parking/all: client is not connected
2023-09-15 12:35:54.307433602  [2023-09-15 14:35:54] frigate.comms.mqtt             ERROR   : Unable to publish to jardin/all: client is not connected
2023-09-15 12:35:55.337292014  [2023-09-15 14:35:55] frigate.watchdog               INFO    : Detection appears to have stopped. Exiting Frigate...
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service nginx: stopping
s6-rc: info: service go2rtc-healthcheck: stopping
2023-09-15 12:35:56.687870845  [INFO] The go2rtc-healthcheck service exited with code 256 (by signal 15)
s6-rc: info: service go2rtc-healthcheck successfully stopped
2023-09-15 12:35:56.706645780  [INFO] Service NGINX exited with code 0 (by signal 0)
s6-rc: info: service nginx successfully stopped
s6-rc: info: service nginx-log: stopping
s6-rc: info: service frigate: stopping
2023-09-15 12:35:56.728936513  [2023-09-15 14:35:56] frigate.app                    INFO    : Stopping...
2023-09-15 12:35:56.732034647  [2023-09-15 14:35:56] frigate.events                 INFO    : Exiting event cleanup...
2023-09-15 12:35:56.755789949  [2023-09-15 14:35:56] frigate.record                 INFO    : Exiting recording cleanup...
2023-09-15 12:35:56.756358854  [2023-09-15 14:35:56] frigate.storage                INFO    : Exiting storage maintainer...
2023-09-15 12:35:56.756646723  [2023-09-15 14:35:56] frigate.watchdog               INFO    : Exiting watchdog...
2023-09-15 12:35:56.757501922  [2023-09-15 14:35:56] frigate.object_processing      INFO    : Exiting object processor...
2023-09-15 12:35:56.761310794  [2023-09-15 14:35:56] frigate.stats                  INFO    : Exiting stats emitter...
s6-rc: info: service nginx-log successfully stopped
2023-09-15 12:35:57.295208203  [2023-09-15 14:35:57] frigate.comms.ws               INFO    : Exiting websocket client...
2023-09-15 12:35:58.399026174  [2023-09-15 14:35:58] frigate.events                 INFO    : Exiting event processor...
2023-09-15 12:35:58.479801628  [2023-09-15 14:35:58] frigate.record                 ERROR   : Error occurred when attempting to maintain recording cache
2023-09-15 12:35:58.482048210  [2023-09-15 14:35:58] frigate.record                 ERROR   : list index out of range
2023-09-15 12:35:58.482061655  [2023-09-15 14:35:58] frigate.record                 INFO    : Exiting recording maintenance...
2023-09-15 12:35:58.482276228  [2023-09-15 14:35:58] peewee.sqliteq                 INFO    : writer received shutdown request, exiting.
2023-09-15 12:35:58.520597316  [2023-09-15 14:35:58] watchdog.jardin                INFO    : Terminating the existing ffmpeg process...
2023-09-15 12:35:58.521762051  [2023-09-15 14:35:58] watchdog.jardin                INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-15 12:35:58.522672658  [2023-09-15 14:35:58] watchdog.parking               INFO    : Terminating the existing ffmpeg process...
2023-09-15 12:35:58.523465544  [2023-09-15 14:35:58] watchdog.parking               INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-15 12:35:58.580283567  [2023-09-15 14:35:58] watchdog.parking               INFO    : Terminating the existing ffmpeg process...
2023-09-15 12:35:58.581319137  [2023-09-15 14:35:58] watchdog.parking               INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-15 12:35:58.585156860  [2023-09-15 14:35:58] watchdog.jardin                INFO    : Terminating the existing ffmpeg process...
2023-09-15 12:35:58.585982931  [2023-09-15 14:35:58] watchdog.jardin                INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-15 12:35:59.290192541  [2023-09-15 14:35:59] frigate.output                 INFO    : exiting output process...
2023-09-15 12:36:06.774519166  /usr/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 13 leaked shared_memory objects to clean up at shutdown
2023-09-15 12:36:06.774561443    warnings.warn('resource_tracker: There appear to be %d '
2023-09-15 12:36:06.828236777  [INFO] Service Frigate exited with code 0 (by signal 0)
s6-rc: info: service frigate successfully stopped
s6-rc: info: service go2rtc: stopping
s6-rc: info: service frigate-log: stopping
2023-09-15 12:36:06.848622316  exit OK
s6-rc: info: service frigate-log successfully stopped
2023-09-15 12:36:06.873036151  [INFO] The go2rtc service exited with code 0 (by signal 0)
s6-rc: info: service go2rtc successfully stopped
s6-rc: info: service go2rtc-log: stopping
s6-rc: info: service go2rtc-log successfully stopped
s6-rc: info: service log-prepare: stopping
s6-rc: info: service s6rc-fdholder: stopping
s6-rc: info: service log-prepare successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service s6rc-fdholder successfully stopped
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
NickM-27 commented 1 year ago

which addon are you running?

lahayeg commented 1 year ago

Standard one, not the full access. I revert back my config and restart hardware, back to normal.

If I set again the custom model, any risk to "burn" my coral?

NickM-27 commented 1 year ago

If I set again the custom model, any risk to "burn" my coral?

I don't see why it would

lahayeg commented 1 year ago

tried again

model:
  path: /config/frigate/efficientdet_lite3x_640_ptq_edgetpu.tflite
  labelmap_path: /config/frigate/coco_labels.txt
  width: 640
  height: 640

and same behaviour

2023-09-15 12:35:40.463255816  Process detector:coral:
2023-09-15 12:35:40.470000971  [2023-09-15 14:35:40] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2023-09-15 12:35:40.478366563  Traceback (most recent call last):
2023-09-15 12:35:40.478451915    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2023-09-15 12:35:40.478456415      delegate = Delegate(library, options)
2023-09-15 12:35:40.478460822    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2023-09-15 12:35:40.478532951      raise ValueError(capture.message)
2023-09-15 12:35:40.478678765  ValueError
2023-09-15 12:35:40.478683136  
2023-09-15 12:35:40.478686895  During handling of the above exception, another exception occurred:
2023-09-15 12:35:40.478688636  
2023-09-15 12:35:40.478691191  Traceback (most recent call last):

Does someone else managed to update edgetpu model using Hassio Frigate addon on RPI4 + Coral USB?

lahayeg commented 1 year ago

tried to put model at /config/ level and still error in log

2023-09-18 14:19:45.275120933  [2023-09-18 16:19:45] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-09-18 14:19:45.315010113  [2023-09-18 16:19:45] frigate.app                    INFO    : Camera processor started for parking: 305
2023-09-18 14:19:45.335813319  [2023-09-18 16:19:45] frigate.app                    INFO    : Camera processor started for jardin: 309
2023-09-18 14:19:45.369537976  [2023-09-18 16:19:45] frigate.app                    INFO    : Capture process started for parking: 311
2023-09-18 14:19:45.391364399  [2023-09-18 16:19:45] frigate.app                    INFO    : Capture process started for jardin: 314
2023-09-18 14:19:48.175596150  [INFO] Starting go2rtc healthcheck service...
2023-09-18 14:19:48.423341595  [2023-09-18 16:19:48] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-09-18 14:19:51.867861235  172.30.32.1 - - [18/Sep/2023:16:19:51 +0200] "GET /api/stats HTTP/1.1" 200 2369 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-18 14:19:54.581997422  Process detector:coral:
2023-09-18 14:19:54.619912613  Traceback (most recent call last):
2023-09-18 14:19:54.620353055    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-09-18 14:19:54.620361148      self.run()
2023-09-18 14:19:54.620946978    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-09-18 14:19:54.620958441      self._target(*self._args, **self._kwargs)
2023-09-18 14:19:54.621425883    File "/opt/frigate/frigate/object_detection.py", line 121, in run_detector
2023-09-18 14:19:54.621435216      detections = object_detector.detect_raw(input_frame)
2023-09-18 14:19:54.621935732    File "/opt/frigate/frigate/object_detection.py", line 71, in detect_raw
2023-09-18 14:19:54.621943862      return self.detect_api.detect_raw(tensor_input=tensor_input)
2023-09-18 14:19:54.622480822    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 55, in detect_raw
2023-09-18 14:19:54.622490229      self.interpreter.set_tensor(self.tensor_input_details[0]["index"], tensor_input)
2023-09-18 14:19:54.622971245    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 572, in set_tensor
2023-09-18 14:19:54.622979357      self._interpreter.SetTensor(tensor_index, value)
2023-09-18 14:19:54.623496224  ValueError: Cannot set tensor: Dimension mismatch. Got 320 but expected 300 for dimension 1 of input 0.
2023-09-18 14:19:59.718593968  172.30.32.1 - - [18/Sep/2023:16:19:59 +0200] "GET /api/stats HTTP/1.1" 200 2387 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-18 14:20:02.651857659  [2023-09-18 16:20:02] frigate.record                 ERROR   : Error occurred when attempting to maintain recording cache
2023-09-18 14:20:02.652596173  [2023-09-18 16:20:02] frigate.record                 ERROR   : list index out of range
2023-09-18 14:20:05.869771150  [2023-09-18 16:20:05] frigate.watchdog               INFO    : Detection appears to be stuck. Restarting detection process...
2023-09-18 14:20:05.912939425  [2023-09-18 16:20:05] detector.coral                 INFO    : Starting detection process: 376
2023-09-18 14:20:05.959856328  [2023-09-18 16:20:05] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-09-18 14:20:07.713623553  172.30.32.1 - - [18/Sep/2023:16:20:07 +0200] "GET /api/stats HTTP/1.1" 200 2424 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-18 14:20:08.704941070  [2023-09-18 16:20:08] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-09-18 14:20:08.745346619  Process detector:coral:
2023-09-18 14:20:09.042902605  Traceback (most recent call last):
2023-09-18 14:20:09.043887470    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-09-18 14:20:09.043899025      self.run()
2023-09-18 14:20:09.044046765    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-09-18 14:20:09.044052914      self._target(*self._args, **self._kwargs)
2023-09-18 14:20:09.044866169    File "/opt/frigate/frigate/object_detection.py", line 121, in run_detector
2023-09-18 14:20:09.044876928      detections = object_detector.detect_raw(input_frame)
2023-09-18 14:20:09.045049131    File "/opt/frigate/frigate/object_detection.py", line 71, in detect_raw
2023-09-18 14:20:09.045055834      return self.detect_api.detect_raw(tensor_input=tensor_input)
2023-09-18 14:20:09.045175408    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 55, in detect_raw
2023-09-18 14:20:09.045181871      self.interpreter.set_tensor(self.tensor_input_details[0]["index"], tensor_input)
2023-09-18 14:20:09.045298722    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 572, in set_tensor
2023-09-18 14:20:09.045304166      self._interpreter.SetTensor(tensor_index, value)
2023-09-18 14:20:09.045472869  ValueError: Cannot set tensor: Dimension mismatch. Got 320 but expected 300 for dimension 1 of input 0.
2023-09-18 14:20:15.892636843  [2023-09-18 16:20:15] frigate.watchdog               INFO    : Detection appears to have stopped. Exiting Frigate...
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service nginx: stopping
s6-rc: info: service go2rtc-healthcheck: stopping
2023-09-18 14:20:16.112859770  [INFO] The go2rtc-healthcheck service exited with code 256 (by signal 15)
s6-rc: info: service go2rtc-healthcheck successfully stopped
2023-09-18 14:20:16.134032160  [INFO] Service NGINX exited with code 0 (by signal 0)
s6-rc: info: service nginx successfully stopped
s6-rc: info: service nginx-log: stopping
s6-rc: info: service frigate: stopping
2023-09-18 14:20:16.151328181  [2023-09-18 16:20:16] frigate.app                    INFO    : Stopping...
s6-rc: info: service nginx-log successfully stopped
2023-09-18 14:20:16.154824718  [2023-09-18 16:20:16] frigate.stats                  INFO    : Exiting stats emitter...
2023-09-18 14:20:16.163884393  [2023-09-18 16:20:16] frigate.events                 INFO    : Exiting event cleanup...
2023-09-18 14:20:16.168559795  [2023-09-18 16:20:16] frigate.record                 INFO    : Exiting recording cleanup...
2023-09-18 14:20:16.177355360  [2023-09-18 16:20:16] frigate.record                 INFO    : Exiting recording maintenance...
2023-09-18 14:20:16.179017999  [2023-09-18 16:20:16] frigate.watchdog               INFO    : Exiting watchdog...
2023-09-18 14:20:16.182806035  [2023-09-18 16:20:16] frigate.storage                INFO    : Exiting storage maintainer...
2023-09-18 14:20:16.183382662  [2023-09-18 16:20:16] frigate.object_processing      INFO    : Exiting object processor...
2023-09-18 14:20:16.220495654  [2023-09-18 16:20:16] frigate.comms.ws               INFO    : Exiting websocket client...
2023-09-18 14:20:16.953940816  [2023-09-18 16:20:16] frigate.events                 INFO    : Exiting event processor...
2023-09-18 14:20:16.956653913  [2023-09-18 16:20:16] peewee.sqliteq                 INFO    : writer received shutdown request, exiting.
2023-09-18 14:20:16.965275091  [2023-09-18 16:20:16] watchdog.parking               INFO    : Terminating the existing ffmpeg process...
2023-09-18 14:20:16.968204668  [2023-09-18 16:20:16] watchdog.parking               INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-18 14:20:16.968217334  [2023-09-18 16:20:16] watchdog.jardin                INFO    : Terminating the existing ffmpeg process...
2023-09-18 14:20:16.969451902  [2023-09-18 16:20:16] watchdog.jardin                INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-18 14:20:17.035664150  [2023-09-18 16:20:17] watchdog.jardin                INFO    : Terminating the existing ffmpeg process...
2023-09-18 14:20:17.036584923  [2023-09-18 16:20:17] watchdog.jardin                INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-18 14:20:17.040866660  [2023-09-18 16:20:17] watchdog.parking               INFO    : Terminating the existing ffmpeg process...
2023-09-18 14:20:17.041841970  [2023-09-18 16:20:17] watchdog.parking               INFO    : Waiting for ffmpeg to exit gracefully...
2023-09-18 14:20:17.475984746  [2023-09-18 16:20:17] frigate.output                 INFO    : exiting output process...
2023-09-18 14:20:22.815334386  /usr/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 11 leaked shared_memory objects to clean up at shutdown
2023-09-18 14:20:22.815346274    warnings.warn('resource_tracker: There appear to be %d '
2023-09-18 14:20:22.829562423  [INFO] Service Frigate exited with code 0 (by signal 0)
s6-rc: info: service frigate successfully stopped
s6-rc: info: service go2rtc: stopping
s6-rc: info: service frigate-log: stopping
2023-09-18 14:20:22.851430883  exit OK
s6-rc: info: service frigate-log successfully stopped
2023-09-18 14:20:22.873305140  [INFO] The go2rtc service exited with code 0 (by signal 0)
s6-rc: info: service go2rtc successfully stopped
s6-rc: info: service go2rtc-log: stopping
s6-rc: info: service go2rtc-log successfully stopped
s6-rc: info: service log-prepare: stopping
s6-rc: info: service s6rc-fdholder: stopping
s6-rc: info: service log-prepare successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service s6rc-fdholder successfully stopped
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
NickM-27 commented 1 year ago

ValueError: Cannot set tensor: Dimension mismatch. Got 320 but expected 300 for dimension 1 of input 0.

looks like a config error now

lahayeg commented 1 year ago

Thanks @NickM-27 to pointing it

several tried: with the correct size (300 as defined by the Coral doc instead of the default 320)

model:
  path: /config/frigate/ssd_mobilenet_v1_coco_quant_postprocess_edgetpu.tflite
  labelmap_path: /config/frigate/coco_labels.txt
  width: 300
  height: 300

works perfectly

then

model:
  path: /config/frigate/efficientdet_lite3x_640_ptq_edgetpu.tflite
  labelmap_path: /config/frigate/coco_labels.txt
  width: 640
  height: 640

reported error:

2023-09-19 08:55:42.600572473  [INFO] Starting go2rtc healthcheck service...
2023-09-19 08:55:43.639729402  [2023-09-19 10:55:42] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-09-19 08:55:47.017318492  172.30.32.1 - - [19/Sep/2023:10:55:47 +0200] "GET /api/stats HTTP/1.1" 200 2367 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-19 08:55:53.518402742  F driver/usb/usb_driver.cc:857] transfer on tag 1 failed. Abort. Deadline exceeded: USB transfer error 2 [LibUsbDataOutCallback]
2023-09-19 08:55:53.518418001  Fatal Python error: Aborted
2023-09-19 08:55:53.518421260  
2023-09-19 08:55:53.518423983  Thread 0x0000007f6bf7e1e0 (most recent call first):
2023-09-19 08:55:53.518428057    File "/usr/lib/python3.9/threading.py", line 312 in wait
2023-09-19 08:55:53.518558889    File "/usr/lib/python3.9/multiprocessing/queues.py", line 233 in _feed
2023-09-19 08:55:53.518638981    File "/usr/lib/python3.9/threading.py", line 892 in run
2023-09-19 08:55:53.518855462    File "/usr/lib/python3.9/threading.py", line 954 in _bootstrap_inner
2023-09-19 08:55:53.519023276    File "/usr/lib/python3.9/threading.py", line 912 in _bootstrap
2023-09-19 08:55:53.519055720  
2023-09-19 08:55:53.519058479  Thread 0x0000007f8c3b7010 (most recent call first):
2023-09-19 08:55:53.519327718    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 833 in invoke
2023-09-19 08:55:53.519576680    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 56 in detect_raw
2023-09-19 08:55:53.519799604    File "/opt/frigate/frigate/object_detection.py", line 71 in detect_raw
2023-09-19 08:55:53.520022344    File "/opt/frigate/frigate/object_detection.py", line 121 in run_detector
2023-09-19 08:55:53.520222250    File "/usr/lib/python3.9/multiprocessing/process.py", line 108 in run
2023-09-19 08:55:53.520454823    File "/usr/lib/python3.9/multiprocessing/process.py", line 315 in _bootstrap
2023-09-19 08:55:53.520687914    File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 71 in _launch
2023-09-19 08:55:53.520932302    File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 19 in __init__
2023-09-19 08:55:53.521140949    File "/usr/lib/python3.9/multiprocessing/context.py", line 277 in _Popen
2023-09-19 08:55:53.521361336    File "/usr/lib/python3.9/multiprocessing/context.py", line 224 in _Popen
2023-09-19 08:55:53.521582687    File "/usr/lib/python3.9/multiprocessing/process.py", line 121 in start
2023-09-19 08:55:53.521815704    File "/opt/frigate/frigate/object_detection.py", line 179 in start_or_restart
2023-09-19 08:55:53.522014999    File "/opt/frigate/frigate/object_detection.py", line 147 in __init__
2023-09-19 08:55:53.522214998    File "/opt/frigate/frigate/app.py", line 214 in start_detectors
2023-09-19 08:55:53.525923958    File "/opt/frigate/frigate/app.py", line 379 in start
2023-09-19 08:55:53.526718620    File "/opt/frigate/frigate/__main__.py", line 16 in <module>
2023-09-19 08:55:53.527426320    File "/usr/lib/python3.9/runpy.py", line 87 in _run_code
2023-09-19 08:55:53.528119557    File "/usr/lib/python3.9/runpy.py", line 197 in _run_module_as_main
2023-09-19 08:55:55.709484138  172.30.32.1 - - [19/Sep/2023:10:55:55 +0200] "GET /api/stats HTTP/1.1" 200 2384 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-19 08:55:58.408224790  [2023-09-19 10:55:58] frigate.record                 ERROR   : Error occurred when attempting to maintain recording cache
2023-09-19 08:55:58.409969891  [2023-09-19 10:55:58] frigate.record                 ERROR   : list index out of range
2023-09-19 08:56:01.027481398  [2023-09-19 10:56:01] frigate.watchdog               INFO    : Detection appears to be stuck. Restarting detection process...
2023-09-19 08:56:01.076344636  [2023-09-19 10:56:01] detector.coral                 INFO    : Starting detection process: 377
2023-09-19 08:56:01.082397657  [2023-09-19 10:56:01] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-09-19 08:56:03.758002794  172.30.32.1 - - [19/Sep/2023:10:56:03 +0200] "GET /api/stats HTTP/1.1" 200 2417 "-" "HomeAssistant/2023.9.2 aiohttp/3.8.5 Python/3.11" "-"
2023-09-19 08:56:07.147917631  [2023-09-19 10:56:07] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.
2023-09-19 08:56:07.147929483  Process detector:coral:
2023-09-19 08:56:07.166559691  Traceback (most recent call last):
2023-09-19 08:56:07.166648524    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2023-09-19 08:56:07.166659412      delegate = Delegate(library, options)
2023-09-19 08:56:07.166662857    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2023-09-19 08:56:07.166664986      raise ValueError(capture.message)
2023-09-19 08:56:07.166666579  ValueError
2023-09-19 08:56:07.166719727  
2023-09-19 08:56:07.166723727  During handling of the above exception, another exception occurred:
2023-09-19 08:56:07.166725079  
2023-09-19 08:56:07.166760893  Traceback (most recent call last):
2023-09-19 08:56:07.166891152    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2023-09-19 08:56:07.166895559      self.run()
2023-09-19 08:56:07.166898059    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2023-09-19 08:56:07.166900133      self._target(*self._args, **self._kwargs)
2023-09-19 08:56:07.166902670    File "/opt/frigate/frigate/object_detection.py", line 98, in run_detector
2023-09-19 08:56:07.166905133      object_detector = LocalObjectDetector(detector_config=detector_config)
2023-09-19 08:56:07.166995151    File "/opt/frigate/frigate/object_detection.py", line 52, in __init__
2023-09-19 08:56:07.167000133      self.detect_api = create_detector(detector_config)
2023-09-19 08:56:07.167093021    File "/opt/frigate/frigate/detectors/__init__.py", line 24, in create_detector
2023-09-19 08:56:07.167096299      return api(detector_config)
2023-09-19 08:56:07.167098984    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 37, in __init__
2023-09-19 08:56:07.167101521      edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2023-09-19 08:56:07.167104410    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2023-09-19 08:56:07.167106780      raise ValueError('Failed to load delegate from {}\n{}'.format(
2023-09-19 08:56:07.167108984  ValueError: Failed to load delegate from libedgetpu.so.1.0
2023-09-19 08:56:07.167110262  
2023-09-19 08:56:11.049940883  [2023-09-19 10:56:11] frigate.watchdog               INFO    : Detection appears to have stopped. Exiting Frigate...
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
lahayeg commented 1 year ago

Sorry just saw the comment on Coral:

* EfficientDet-Lite3x is not compatible with Edge TPUs over USB; it can be used only with PCIe-based devices. Our benchmarks for EfficientDet-Lite3x come from a desktop system paired with the Asus AI Accelerator—your results will vary.

lahayeg commented 1 year ago

Tested with efficientdet_lite3_512_ptq_edgetpu.tflite and same issue. I don't want to waste more time for everyone so I prefer to close it (won't do ;-)

lahayeg commented 1 year ago

lol : I restarted my RPI4 with

model:
  path: /config/frigate/efficientdet_lite3_512_ptq_edgetpu.tflite
  labelmap_path: /config/frigate/coco_labels.txt
  width: 512
  height: 512

And it works...