ZMEventNotification Trying to use CSPN weights. Getting an error.

Discussion topics related to mobile applications for ZoneMinder
Post Reply
BaconButty
Posts: 25
Joined: Fri Jun 12, 2020 1:29 pm

ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by BaconButty » Sat Jun 13, 2020 7:31 pm

Hi,

I'm trying to try the CSPN weights as the docs say they are more accurate than the standard YOLOV ones (which have had a few false positives for me).

I'm getting the following error:

Code: Select all

Traceback (most recent call last):
  File "/var/cache/zoneminder/zmeventnotification/bin/zm_detect.py", line 398, in <module>
    b, l, c = m.detect(image)
  File "/usr/local/lib/python3.8/dist-packages/zmes_hook_helpers/yolo.py", line 64, in detect
    self.net = cv2.dnn.readNet(weights_file_abs_path,
cv2.error: OpenCV(4.4.0-pre) /var/cache/zoneminder/OpenCVinstall/opencv/modules/dnn/src/darknet/darknet_importer.cpp:214: error: (-212:Parsing error) Failed to parse NetParameter file: /var/cache/zoneminder/zmeventnotification/models/cspn/csresnext50-panet-spp-original-optimal_final.weights in function 'readNetFromDarknet'
I've double checked and the file path is correct, the weights file is there.
I'm currently running OpenCV V4.4

Have I missed something else here? From the docs it says to leave the model type as Yolov and just change the weights, maybe I misunderstood this?

Here's what I changed in objectconfig.ini

Code: Select all

#remove temp
#config={{base_data_path}}/models/yolov3/yolov3.cfg
#weights={{base_data_path}}/models/yolov3/yolov3.weights
#labels={{base_data_path}}/models/yolov3/yolov3_classes.txt
#End rem

#Copied from the git:
# FOR CSPN. Note that model name is yolo
config={{base_data_path}}/models/cspn/csresnext50-panet-spp-original-optimal.cfg
weights={{base_data_path}}/models/cspn/csresnext50-panet-spp-original-optimal_final.weights
labels={{base_data_path}}/models/cspn/coco.names


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

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by asker » Sat Jun 13, 2020 9:08 pm

1. Can you check those weights exist? Remember, the install does not download the weights for you.
2. If they exist, can you try re-downloading them? Sometimes, the download is messed up

Code: Select all

pp@homeserver:/var/lib/zmeventnotification/models/cspn$ ls -l
total 222796
-rw-r--r-- 1 www-data www-data       625 Apr 15 14:00 coco.names
-rw-r--r-- 1 www-data www-data     10993 Apr 15 11:59 csresnext50-panet-spp-original-optimal.cfg
-rw-r--r-- 1 www-data www-data 228123400 Apr 15 11:59 csresnext50-panet-spp-original-optimal_final.weights
And finally, after running cspn for a while now, I've come to realize it also produces false positives. It happens to be faster than yolov3 but I'm not really sure it is that much more accurate (even though the authors claim it to be so)
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

BaconButty
Posts: 25
Joined: Fri Jun 12, 2020 1:29 pm

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by BaconButty » Sat Jun 13, 2020 10:10 pm

Hi!

Right, so I went to run the same command to show that the folder was correct. It had the file name highlighted in yellow and the output looked like this:

Code: Select all

-rw-r--r-- 1 www-data www-data       625 Jun 12 19:20 coco.names
-rw-r--r-- 1 www-data www-data     10993 Jun 12 19:20 csresnext50-panet-spp-original-optimal.cfg
-rw---S--- 1 isabell  www-data 228123400 Jun 13 18:48 csresnext50-panet-spp-original-optimal_final.weights
I did try and set the file permissions to make sure they where correct before making this post, but I obviously got it wrong (highlighted by this command).

I don't really understand these so I just ran a sudo chmod --reference using one of the other files in the folder and now it works!

What you've said about it not being as accurate maybe true though. The very first detection it detected a flowerpot as a cup.. (I've flowerpots disabled)

Thanks for the help!

BaconButty
Posts: 25
Joined: Fri Jun 12, 2020 1:29 pm

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by BaconButty » Sat Jun 13, 2020 11:10 pm

Do you mind if I ask you a question while I have you here?

This is having horrible issues with detection at night time. My cameras switch to 10FPS mode at night to allow more light in for detail, I don't think this is the issue though. Is there something I can debug on how OpenCV is processing the image to see why it's missing objects that are clearly people? I've tried manually running the image, but it made no difference. One of the cameras has the IR filter turned off, and it is working fine, so I'm wondering is something happening with colour filter that's ruining the image before it hits OpenCV.

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

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by asker » Sun Jun 14, 2020 4:08 pm

BaconButty wrote:
Sat Jun 13, 2020 11:10 pm
Do you mind if I ask you a question while I have you here?

This is having horrible issues with detection at night time. My cameras switch to 10FPS mode at night to allow more light in for detail, I don't think this is the issue though. Is there something I can debug on how OpenCV is processing the image to see why it's missing objects that are clearly people? I've tried manually running the image, but it made no difference. One of the cameras has the IR filter turned off, and it is working fine, so I'm wondering is something happening with colour filter that's ruining the image before it hits OpenCV.
Not really. It is not exactly OpenCV that is analyzing the image. It is the neural network that is trying to match its many millions of connections (the weights file) to see what label the input image finally matches to. Trying to figure out how the network navigates all the connections is something that is extremely hard to do, even for PhDs in this field. What most people do, instead, is they "retrain" their model with new images that its mislabeling. In your case, you can try retraining the model with images that it is missing. You'll have to google for the procedure. If you want to go that route, start here and look at the instructions in the readme https://github.com/AlexeyAB/darknet
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

BaconButty
Posts: 25
Joined: Fri Jun 12, 2020 1:29 pm

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by BaconButty » Sun Jun 14, 2020 9:53 pm

Ah OK. Really appreciate the detailed reply.

Don't think it's worth while looking into this then. It's one event it missed out of around 100, and the person was captured in another event anyway.

Thanks again!

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

Re: ZMEventNotification Trying to use CSPN weights. Getting an error.

Post by asker » Tue Jun 16, 2020 2:20 pm

Note that you should also experiment with the confidence thresholds to see if adjusting them makes a difference. Typically debug logs will tell you if it actually detected a person, but maybe got rejected since the confidence level was lower than the configured threshold (0.3 is the default). Of course, the unintended effect of this may also be you start getting false positives.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests