snowzach / doods2

API for detecting objects in images and video streams using Tensorflow
MIT License
232 stars 30 forks source link

help: is my EdgeTPU working properly #110

Closed kimpenhaus closed 2 months ago

kimpenhaus commented 3 months ago

hey @snowzach,

this is actually not a bug but more a question - and I am really sorry for that - cause I am not pretty sure if my EdgeTPU is working properly.

I have doods2 running on a Beelink Mini S12 Pro, with Ubuntu Server 24.04 installed, inside docker (image is latest). I have installed the drivers accordingly and running lsusb on the host gives (as far as I can tell) the correct output:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 18d1:9302 Google Inc. 

the docker-cmpose has the /dev/bus/usb mapped proper:

  doods2:
    container_name: dc_doods
    image: snowzach/doods2:latest
    labels:
      com.centurylinklabs.watchtower.enable: true
      traefik.enable: true
      traefik.http.routers.doods.middlewares: 'https_redirect@file'
      traefik.http.routers.doods.rule: 'Host(`doods.domain.net`)'
      traefik.http.routers.doods.entrypoints: 'web, web-secure'
      traefik.http.services.doods.loadbalancer.server.port: 8080
    devices:
      - /dev/bus/usb:/dev/bus/usb
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /srv/nfs/docker/doods2/config.yaml:/app/config.yaml
      - /srv/nfs/docker/doods2/models:/app/models
    environment:
      - CONFIG_FILE=/app/config.yaml
    restart: unless-stopped
    stop_grace_period: 30s

My doods 2 server is configured as follows - mind the edgetpu model and hwaccel true setting:

  detectors:
    - name: default
      type: tflite
      modelFile: /app/models/tf2_ssd_mobilenet_v1_fpn_640x640_coco17_ptq_edgetpu.tflite
      labelFile: /app/models/coco_labels_tf2_ssd_mobilenet_v1_fpn_640x640_coco17_ptq_edgetpu.txt
      hwAccel: True

when connection the bash in the docker and running lsusb - it shows the following which slightly confuses me:

Bus 002 Device 002: ID 18d1:9302  
Bus 002 Device 001: ID 1d6b:0003 Linux 6.8.0-36-generic xhci-hcd xHCI Host Controller
Bus 001 Device 002: ID 8087:0026  
Bus 001 Device 001: ID 1d6b:0002 Linux 6.8.0-36-generic xhci-hcd xHCI Host Controller

next thing is the logs when starting the server - which says for CPU:

INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
2024-06-28 08:47:22,844 - doods.doods - INFO - Registered detector type:tflite name:default
2024-06-28 08:47:22,876 - uvicorn.error - INFO - Started server process [1]

when detecing an image the edgetpu modeel seems to be working - but I wonder if it is cpu-based detection or with the EdgeTPU: (sample with stock image)

grafik
{
  "id": "manual",
  "detections": [
    {
      "top": 0.013015419244766235,
      "left": 0.22488349676132202,
      "bottom": 0.995612382888794,
      "right": 0.7756258845329285,
      "label": "person",
      "confidence": 80.078125
    }
  ],
  "duration": 300
}

is there any chance to see if it using the tpu?

thanks for any help 🙏🏼

snowzach commented 2 months ago

If you are using a model that has edgetpu in the filename, it's using the TPU. Generally it will fail if you arent. If you want to verify, unplug and try without it.. It shouldn't work.

kimpenhaus commented 2 months ago

perfect - thanks for the hint. 👍🏼