snowzach / doods2

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

Troubleshooting/Documenting EdgeTPU usage with DOODS2 running in a Proxmox LXC #66

Closed tokenwizard closed 1 year ago

tokenwizard commented 1 year ago

Looking through the documentation in the README section, it seems like if you want to use edgeTPU, you need to create a docker-compose.yaml like the example provided so you can pass the device to the DOODS container. It also looks like you need to create a config.yaml to add the edgeTPU Detector.

There is mention that it will look for the config.yaml in the current working directory and if it does not see one it will use the built-in config in the image. Is that correct?

I have this folder structure:

~/doods2$ ls -lah total 20K drwxr-xr-x 3 doods doods 4.0K Nov 7 10:50 . drwxr-xr-x 4 doods doods 4.0K Nov 7 09:48 .. -rw-r--r-- 1 doods doods 1.1K Nov 4 11:15 config.yaml -rw-r--r-- 1 doods doods 144 Nov 7 09:52 docker-compose.yaml drwxr-xr-x 2 doods doods 4.0K Nov 4 11:14 models

In my config.yaml, I have added a third detector called edgeTPU and it references the models folder for the model and labels.

detectors:

And in my docker-compose.yaml, I have the USB device passed:

version: '3.2' services: doods: image: snowzach/doods2:amd64-gpu ports:

For some reason, I am only getting the two default detectors as options. I'm not sure if I'm missing a step that may not be documented, or if it is just ignoring my config.yaml and using the built-in one for some reason.

Screenshot_2022-11-07-14-31-21_2560x1080

Any ideas?

TIA!

snowzach commented 1 year ago

You need to pass in the config file and the models file to the docker container. Try adding this to your docker compose file:

volumes:
  - ./models:/opt/doods/models
  - ./config.yaml:/opt/doods/config.yaml
tokenwizard commented 1 year ago

Ah, I knew I was missing something simple. I'm a late bloomer with all this docker stuff.

------- Original Message ------- On Wednesday, November 9th, 2022 at 8:53 AM, Zach @.***> wrote:

You need to pass in the config file and the models file to the docker container. Try adding this to your docker compose file:

volumes:

  • ./models:/opt/doods/models
  • ./config.yaml:/opt/doods/config.yaml

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

tokenwizard commented 1 year ago

Ok, I spun up a fresh LXC in Proxmox and confirmed my USB Coral device is showing up in the container. Per some guidance I found on Proxmox forums I added a udev rule to create a symlink for the coral device at /dev/CoralUSB. I then confirmed that the Coral device is working directly on the Proxmox server, and it is showing up inside the Proxmox LXC.

image

Then I added that USB device to my docker-compose.yaml and added the edgeTPU detector to my config.yaml (commented out the default and tensorflow ones since my models folder only includes the edgeTPU model and labels).

image

image

I also added the config and models volumes to the docker-compose.yaml as you can see in the above screenshot.

Are all the edgeTPU drivers/dependencies included in the DOODS2 container? Should this just work "out of the box" as long as the USB device is recognized on the device running the DOODS2 container?

This is what I am getting when I start up the DOODS2 container: image

tokenwizard commented 1 year ago

I can load the web GUI but there are no detectors configured, since the edgeTPU failed.

snowzach commented 1 year ago

There's something automatic the library uses to find the Coral... Its not likely looking for it at your udev alias.. Try using /dev/bus/usb instead.

tokenwizard commented 1 year ago

Ok, I updated my LXC config to pass the whole USB bus to the LXC container. image

Then I verified that I can use the Coral device in the LXC container, so I know the passthrough is working: image

Next, I updated my docker-compose.yaml to pass the USB Bus to the DOODS container: image

Now it is properly getting connected and working in DOODS.

tokenwizard commented 1 year ago

I fed it an image from my security camera and it is pretty confident that this this car is a bicycle.

I will test out some more.

image

snowzach commented 1 year ago

You're probably passing the wrong labels file. There's several coco labels files. Sadly you kinda just gotta try them out until it looks right.

tokenwizard commented 1 year ago

Ok, I downloaded the tflite and labels from the same model at the Coral website. I'll double-check.

------- Original Message ------- On Thursday, November 10th, 2022 at 8:45 AM, Zach @.***> wrote:

You're probably passing the wrong labels file. There's several coco labels files. Sadly you kinda just gotta try them out until it looks right.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

tokenwizard commented 1 year ago

I have tried using the edgeTPU model tflite file with the coco_labels.txt file from the link you include to download them from: image

As well as the v2 for that model with the coco_labels.txt from the test_data of the edgeTPU github project (https://github.com/google-coral/edgetpu/tree/master/test_data)

But both are giving me a label of "bicycle" when I would expect "car." Screenshot_2022-11-10-11-37-53_2560x1080

tokenwizard commented 1 year ago

I posed this over in the edgeTPU project as well, thinking they may be able to point me in the right direction as far as the labels file.

This is the reply I got, which makes sense, because looking at the list, the first three lines are: person bicycle car

image

If the index is off by 1 it would explain why it is returning bicycle when it should be car. Was there a reason for starting at index: 1 for doods? Should there be a modified labels file for use with doods?

tokenwizard commented 1 year ago

Here is a link to the issue I posted on edgeTPU where they seem to indicate a possible fix. I have exec'd into the doods container I'm running and changed the label.py file to use "index: 0" and will test to verify if future labels are correct.

https://github.com/google-coral/edgetpu/issues/681

snowzach commented 1 year ago

Sorry, side tracked on this one...

Added a labels option called labelsStartFromZero: true and it will work off of index 0