snowzach / doods2

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

Instalation with Coral Edge USB (report with issues) #2

Closed mmatesic01 closed 2 years ago

mmatesic01 commented 2 years ago

Hello,

Did the installation and ran docker image with additional » -- device /dev/bus/usb «. You have a typo in your instructions about this parameter.

Then I changed config.yaml in my container and copied model and label file for Edge Coral.

doods: detectors:

  1. http://192.168.xxx.xxx:8080/detectors shows:

{"detectors":[{"name":"default","type":"tensorflow2","model":"models/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite","labels":["person","bicycle","car","motorcycle","airplane","bus","train","truck","boat","traffic light","fire hydrant","n/a","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","n/a","backpack","umbrella","n/a","n/a","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","n/a","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","couch","potted plant","bed","n/a","dining table","n/a","n/a","toilet","n/a","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","n/a","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"],"width":0,"height":0}]}

  1. Additional check upon startup of container

pi@raspberrypi:~ $ sudo docker start 6710fb8a10e2 6710fb8a10e2 pi@raspberrypi:~ $ sudo docker attach 6710fb8a10e2 /usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/init.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: li btensorflow_io_plugins.so, from paths: ['/usr/local/lib/python3.8/dist-packages/ tensorflow_io/python/ops/libtensorflow_io_plugins.so'] caused by: ["[Errno 2] The file to load file system plugin from does not exist.: '/usr/local/lib/python3.8/dist-packages/tensorflowio/python/ops/libtensorflow io_plugins.so'"] warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}") /usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/init.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensor flow_io.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/p ython/ops/libtensorflow_io.so'] caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/lib tensorflow_io.so: cannot open shared object file: No such file or directory'] warnings.warn(f"file system plugins are not loaded: {e}") Failed to load delegate from libedgetpu.so.1.0

INFO: Started server process [1] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)

Question: Is this container related or raspberry bullseye OS?

Mark612 commented 2 years ago

I was able to get tflite models to work, but not the Coral Edge either. Here are my logs:

2022-01-02T21:45:08.513261309Z ERROR: Exception in ASGI application

2022-01-02T21:45:08.513336994Z Traceback (most recent call last):

2022-01-02T21:45:08.513356457Z File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi

2022-01-02T21:45:08.513375827Z result = await app(self.scope, self.receive, self.send)

2022-01-02T21:45:08.513394068Z File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 75, in call

2022-01-02T21:45:08.513412438Z return await self.app(scope, receive, send)

2022-01-02T21:45:08.513430308Z File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 208, in call

2022-01-02T21:45:08.513448623Z await super().call(scope, receive, send)

2022-01-02T21:45:08.513466030Z File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 112, in call

2022-01-02T21:45:08.513484326Z await self.middleware_stack(scope, receive, send)

2022-01-02T21:45:08.513501770Z File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 181, in call

2022-01-02T21:45:08.513519659Z raise exc

2022-01-02T21:45:08.513536826Z File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 159, in call

2022-01-02T21:45:08.513554881Z await self.app(scope, receive, _send)

2022-01-02T21:45:08.513571992Z File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 82, in call

2022-01-02T21:45:08.513589677Z raise exc

2022-01-02T21:45:08.513627973Z File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 71, in call

2022-01-02T21:45:08.513647103Z await self.app(scope, receive, sender)

2022-01-02T21:45:08.513664436Z File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 656, in call

2022-01-02T21:45:08.513719676Z await route.handle(scope, receive, send)

2022-01-02T21:45:08.513737583Z File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 259, in handle

2022-01-02T21:45:08.513754176Z await self.app(scope, receive, send)

2022-01-02T21:45:08.513770528Z File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 61, in app

2022-01-02T21:45:08.513787194Z response = await func(request)

2022-01-02T21:45:08.513803416Z File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 226, in app

2022-01-02T21:45:08.513820064Z raw_response = await run_endpoint_function(

2022-01-02T21:45:08.513836286Z File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 159, in run_endpoint_function

2022-01-02T21:45:08.513852768Z return await dependant.call(**values)

2022-01-02T21:45:08.513869138Z File "/opt/doods/api.py", line 27, in detect

2022-01-02T21:45:08.513885304Z detect_response = self.doods.detect(detect_request)

2022-01-02T21:45:08.513901397Z File "/opt/doods/doods.py", line 108, in detect

2022-01-02T21:45:08.514076192Z ret = detector.detect(image)

2022-01-02T21:45:08.514102562Z File "/opt/doods/detectors/tflite.py", line 72, in detect

2022-01-02T21:45:08.514119506Z label = self.labels[int(classes[i])]

2022-01-02T21:45:08.514135488Z KeyError: 0

mmatesic01 commented 2 years ago

Default configuration also works with me. Configuring doods2 to use Edge Coral breaks something.

snowzach commented 2 years ago

Did the installation and ran docker image with additional » -- device /dev/bus/usb «. You have a typo in your instructions about this parameter. Then I changed config.yaml in my container and copied model and label file for Edge Coral.

I didn't see what typo you were talking about...

The errors you see when it starts are normal. I could not get those libraries to compile on armv7l architecture and it didn't seem to effect DOODS from running...

The error you are having appears to be that the model is returning a label number that's not in the label file. I just updated the code so it will return unknown instead of crash like that. Maybe try pulling the image, checking your label file and trying again?

mmatesic01 commented 2 years ago

EdgeTPU

DOODS2 supports the EdgeTPU hardware accelerator. This requires Tensorflow lite edgetpu.tflite models. In the config you need to set the hwAccel boolean to true for the model and it will load the edgeTPU driver and model. As well, you will need to pass the edgeTPU device to DOODS. This is typically done with the docker flag --device=/dev/bus/usb or in a docker-compose file with:

Is this corrrect »--device=/dev/bus/usb« or not? Or shoudl it be like this? »–- device /dev/bus/usb«

Od: @.> Poslano: torek, 04. januar 2022 15:01 Za: @.> Kp: @.>; @.> Zadeva: Re: [snowzach/doods2] Instalation with Coral Edge USB (report with issues) (Issue #2)

Did the installation and ran docker image with additional » -- device /dev/bus/usb «. You have a typo in your instructions about this parameter. Then I changed config.yaml in my container and copied model and label file for Edge Coral.

I didn't see what typo you were talking about...

The errors you see when it starts are normal. I could not get those libraries to compile on armv7l architecture and it didn't seem to effect DOODS from running...

The error you are having appears to be that the model is returning a label number that's not in the label file. I just updated the code so it will return unknown instead of crash like that. Maybe try pulling the image, checking your label file and trying again?

— Reply to this email directly, view it on GitHubhttps://github.com/snowzach/doods2/issues/2#issuecomment-1004835529, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIZLSDZZT3K6EN265ICWKIDUUL4SZANCNFSM5LD543UA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>

snowzach commented 2 years ago

Is this corrrect »--device=/dev/bus/usb« or not? Or shoudl it be like this? »–- device /dev/bus/usb«

Both should work

mmatesic01 commented 2 years ago

Hi,

OK I'll test,

And which of SSD MobileNet V2 in https://coral.ai/models/object-detection/ woudl you advise to use with Coral Edge TPU?

Thank you.

Od: @.> Poslano: torek, 04. januar 2022 15:49 Za: @.> Kp: @.>; @.> Zadeva: Re: [snowzach/doods2] Instalation with Coral Edge USB (report with issues) (Issue #2)

Is this corrrect »--device=/dev/bus/usb« or not? Or shoudl it be like this? »–- device /dev/bus/usb«

Both should work

— Reply to this email directly, view it on GitHubhttps://github.com/snowzach/doods2/issues/2#issuecomment-1004874357, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIZLSD65GEOOLVSEHPULJY3UUMCJJANCNFSM5LD543UA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>

snowzach commented 2 years ago

Oooo there's a bunch of new ones... I'd try one of those det ones first.

snowzach commented 2 years ago

I tried a couple of the det ones and it couldn't see my truck... I dunno, you'll just have to try.

snowzach commented 2 years ago

Any update? Did you get it to work?

Mark612 commented 2 years ago

I will be able to test/try it again in a couple of weeks. Away from my system for awhile. Perhaps someone is successful before then.

Mark612 commented 2 years ago

I was successful with getting this to run with 2 of my 3 coral edge USB devices, both raspberry pi models. Works great! I was also able to get it going with the new models. As of now, the detection seems to be running faster and more accurate.

Note: if you have an older RPI3 model, and get an error message such as _init_interpmain: can’t initialize time , it is because of an incompatibility with the libseccomp2 library. Not recommended, but you can work around it by adding this in your docker run: ' --security-opt seccomp=unconfined'

Note2: I wish the doods2 logs had more verbose info each time it is called (if an object was detected, which object, which detector, etc). Not sure what is possible in the logs, but a simple IP address with POST message doesn't tell you much.

snowzach commented 2 years ago

Great! I will indeed add some more logging. Closing for now.

snowzach commented 2 years ago

Okay, I added an option for logging the detections. You can set doods.log = all and it will log everything if it matches the filters or not. See the README for info.