ZoneMinder / zmeventnotification

Machine Learning powered Secure Websocket & MQTT based ZoneMinder event notification server
408 stars 128 forks source link

match_past_detections=yes results in zmdetect.py throwing an error #397

Closed lucasnz closed 3 years ago

lucasnz commented 3 years ago

Before you create an issue, please make sure you have read the README. If you are asking about the object detection part, I don't provide support for it unless you've tried hard enough.

Event Server version

You can get the version by doing:

/usr/bin/zmeventnotification.pl --version

6.1.25

Hooks version (if you are using Object Detection)

You can get the version by doing:

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --version

app:6.1.25, pyzm:0.3.49

Are you using MLAPI? (Y/N) No

If you are using MLAPI, please mention the version You can get the version by doing: (change path to wherever you install mlapi)

/var/lib/zmeventnotification/mlapi/mlapi.py --version

The version of ZoneMinder you are using: 1.36.4

What is the nature of your issue

match_past_detections=yes results in zmdetect.py throwing an error

Details

match_past_detections=yes results in zmdetect.py throwing an error.

Changing, match_past_detections=no works around the issue.

When the error occurs notifications are not sent. I think this occurred after a python update or maybe an ES update - I'm not 100% sure which one.

Debug Logs (if applicable)

Important: Please post DEBUG logs NOT INF logs. Instructions on how to enable debug logs are posted HERE


Unrecoverable error:Single '}' encountered in format string Traceback:Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/pyzm/ml/detect_sequence.py", line 242, in _process_past_detections saved_bs = pickle.load(fh)_pickle.UnpicklingError: invalid load key, 'A'.During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/var/lib/zmeventnotification/bin/zm_detect.py", line 556, in main_handler() File "/var/lib/zmeventnotification/bin/zm_detect.py", line 426, in main_handler matched_data,all_data = m.detect_stream(stream=stream, options=stream_options) File "/usr/local/lib/python3.6/dist-packages/pyzm/ml/detect_sequence.py", line 796, in detect_stream matched_b,matched_l,matched_c, matched_detection_types, matched_model_names = self._process_past_detections(matched_b, matched_l, matched_c, matched_detection_types, matched_model_names) File "/usr/local/lib/python3.6/dist-packages/pyzm/ml/detect_sequence.py", line 258, in _process_past_detections g.logger.Error('Error in processPastDetection: e}'.format(e))ValueError: Single '}' encountered in format string

Thanks!

pliablepixels commented 3 years ago

I've fixed the error while printing the error message (missing }). However the core issue may be that your detection state is corrupted for some reason. If the error persists, try deleting /var/lib/zmeventnotification/images/*.pkl and see if they get recreated properly.

lucasnz commented 3 years ago

deleting the pkl files seems to have resolved the issue. I wonder what might have caused the corruption?

pliablepixels commented 3 years ago

Let me know if it happens often. I have a theory its because I release the exclusive locks just after detection happens and its possible that when multiple detections happen, file writes interleave.