zmevennotification object detection on edge tpu

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Sun Jan 10, 2021 3:13 am

Sure. See ml_sequence here https://github.com/pliablepixels/mlapi/ ... config.ini
whether you use mlapi or not the structure is the same.

Also I’ve added more clarifications here https://zmeventnotification.readthedocs ... s-versions on how this works.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Sun Jan 10, 2021 8:44 pm

works great with the sequence but now makes me wonder if its worth having tpu at all, how much is it run on cpu.
I saw this in the config show_models=no, changed it to yes but it does not tag the models in zm.
Is there something extra I need to do?

User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Sun Jan 10, 2021 9:17 pm

You can inspect the logs for now - that will tell you if Yolo got invoked. In my case, Yolo isn't called much, but your case can be different.

show_models worked for me last night - however my server crashed and I can't test till end of Jan (new server will take time to arrive).
I don't recall if I made a pyzm release with the fixed code, but you should make sure you are on the latest pyzm on pip. If it doesn't work, use pyzm master.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Sun Jan 10, 2021 9:22 pm

cheers

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Sun Jan 10, 2021 10:37 pm

Updating just pyzm did not do the trick but then I updated all pip3 packages and it works, sweet.

User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Sun Jan 10, 2021 11:08 pm

Okay. Feel free to post samples.
I have to live life vicariously till I get a new computing environment.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Mon Jan 11, 2021 8:32 pm

For me it's mostly yolo, coral seems to need a clearer picture with whole objects. I don`t mind it at all and I think the sequence works great.
Awesome work asker.

I was thinking about the sequence as it moves to the next step only if the first failed, what if you can run multiple models or weights regardless if it fails or not? For example 1st run object weights then run birds and so on.

User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Tue Jan 12, 2021 2:44 am

You can do that too. Take a look at the docs I linked to above. You can change patterns per model type as well as use most as same model sequence strategy.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Wed Jan 13, 2021 12:43 am

That's super cool, i guess there is no way to keep both detections on the image?

Doing more testing i increased no of processes for cpu and tpu both to 6 (as I got 6 cameras, 3 on mocord) and decreases tpu detection from 0.6 to 0.55 and now it's running mostly coral model, at least during the day.

However I noticed some errors in the logs as coral stopped working after a day:

/zm_detect.py[17684]: ERR [zmesdetect_m5] [Error running model: Failed to load delegate from libedgetpu.so.1#012]

It's still working but last night the logs were filled with this and coral detection stopped working all together. Restarting zm fixed the issue, for now, error still in the logs now and then.

User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Wed Jan 13, 2021 1:07 pm

VicThor wrote:
Wed Jan 13, 2021 12:43 am
Doing more testing i increased no of processes for cpu and tpu both to 6 (as I got 6 cameras, 3 on mocord) and decreases tpu detection from 0.6 to 0.55 and now it's running mostly coral model, at least during the day.

However I noticed some errors in the logs as coral stopped working after a day:

/zm_detect.py[17684]: ERR [zmesdetect_m5] [Error running model: Failed to load delegate from libedgetpu.so.1#012]

What I noticed is doing simultaneous invocations may cause this issue. In my case, I noticed similar errors the moment I increased simultaneous invocations to 3 or more and occasionally on 2. However, I did not test it thoroughly. This is why I keep TPU to 1 as it is pretty fast and I don't mind other invocations hanging around to grab a lock while detections process one at a time.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Thu Jan 14, 2021 3:28 am

Yea, I thought so, does not seem to be able to handle concurrency well, in fact the stick goes in a flashing light mode until re-inserted.

juan11perez
Posts: 18
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez » Tue Jun 15, 2021 7:08 am

Good day. I've added coral in the dlandon docker following all the instructions and when I test with the following I get the below error:

Code: Select all

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --debug --eventid 14891

Code: Select all

06/15/21 10:54:08 zmesdetect[3125] ERR detect_sequence.py:688 [Error running model: Failed to load delegate from libedgetpu.so.1
]

06/15/21 10:54:08 zmesdetect[3125] DBG2 detect_sequence.py:689 [Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 152, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 111, in __init__
    raise ValueError(capture.message)
ValueError
I've searched and came across this post
https://zmeventnotification.readthedocs ... ls-loading

The issue here is that I'm using exactly the same coral half-pcie board in unraid with frigate https://github.com/blakeblackshear/frigate and it works without any issue. Frigate can read and load the coral without any problem.

In this regard I have a question and please excuse my limited knowledge as I'm an enthusiast learning by research, trial and error:

Is there any difference in configuring the ES to load a USB coral or a PCIE based coral ?

One more thing; when I type the following in the zm docker it shows the coral. So it can see it.

Code: Select all

root@UNRAID:/# ls /dev/apex_0
/dev/apex_0
Any guidance is much appreciated. Thank you.

juan11perez
Posts: 18
Joined: Tue Apr 27, 2021 3:41 am

Re: zmevennotification object detection on edge tpu

Post by juan11perez » Fri Jun 18, 2021 10:50 am

So answering my own question; I found the problem. In the container /dev/apex_0 does not have sufficient privileges
chmod 777 /dev/apex_0 >> fixes the problem and the edgetpu loads immediately.

However, the performance is very poor. With the coral and gpu the cpu still spikes to 70% on object detection.

I have modified the objectconfig.ini per the instructions, so not sure what else can be done.

Code: Select all

				'name': 'TPU object detection',
				'enabled': 'yes',

Code: Select all

            'name': 'TPU face detection',
            'enabled': 'yes',
In comparison with Frigate https://github.com/blakeblackshear/frigate the cpu practically stays unchanged.

User avatar
asker
Posts: 1511
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmevennotification object detection on edge tpu

Post by asker » Sat Jun 19, 2021 5:00 pm

Check your logs, make sure TPU is actually being used. Also, use mlapi - if you are loading models on each run, it might cause spikes. In my case, CPU goes from 10%-17% when a detection happens on TPU
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

VicThor
Posts: 32
Joined: Tue Oct 13, 2020 8:47 pm

Re: zmevennotification object detection on edge tpu

Post by VicThor » Mon Jun 21, 2021 9:44 pm

Hey asker, can you keep models always loaded?

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests