Mlapi error when starting detection

Discussion topics related to mobile applications for ZoneMinder
Post Reply
lorenjz
Posts: 29
Joined: Fri Feb 28, 2020 12:25 am

Mlapi error when starting detection

Post by lorenjz » Thu Jan 21, 2021 7:37 pm

I've been trying to setup the mlapi server on a separate vm aside from my event server. Whenever event server sends a task to mlapi the following is thrown:

Code: Select all

Jan 21 2021 18:39:30.762996 [DBG 1] Object Recognition requested
Jan 21 2021 18:39:30.763094 [DBG 1] Stream info not found, looking at args...
Jan 21 2021 18:39:30.763430 [DBG 1] get_file returned: ./images/9d77d499-35a2-4a1d-bf13-a1756ab30839.jpg
192.168.17.60 - - [21/Jan/2021 18:39:30] "POST /api/v1/detect/object?type=object&delete=True HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/werkzeug/serving.py", line 323, in run_wsgi
    execute(self.server.app)
  File "/usr/local/lib/python3.8/dist-packages/werkzeug/serving.py", line 312, in execute
    application_iter = app(environ, start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/flask_jwt_extended/view_decorators.py", line 108, in wrapper
    return fn(*args, **kwargs)
  File "/home/loren/mlapi/mlapi.py", line 153, in post
    g.log.Debug (1, f'Calling detect streams with {stream} and {stream_options} and ml_overrides={ml_overrides} ml_options={ml_options}')
UnboundLocalError: local variable 'ml_overrides' referenced before assignment
Any thoughts on what I missed or didn't configure correctly?

Thank you!

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

Re: Mlapi error when starting detection

Post by asker » Thu Jan 21, 2021 10:18 pm

Fixed in master.
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 29
Joined: Fri Feb 28, 2020 12:25 am

Re: Mlapi error when starting detection

Post by lorenjz » Sun Jan 24, 2021 3:43 am

Thank you. That did the trick.

First thanks for all of the hard work. This platform is fantastic and I appreciate it very much.

Second, does the "training process" change at all if I am using mlapi on a different server then the event server?

Thanks again!

Loren

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

Re: Mlapi error when starting detection

Post by asker » Sun Jan 24, 2021 5:29 pm

mlapi never had a training command line client. I just added one to master.
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 29
Joined: Fri Feb 28, 2020 12:25 am

Re: Mlapi error when starting detection

Post by lorenjz » Mon Jan 25, 2021 12:50 pm

Thanks for the training script...

The Latest development:

Code: Select all

==> /var/log/zm/zmesdetect_m11.log <==
01/25/21 06:34:07 zmesdetect_m11[96245] DBG1 utils.py:195 [Trying to download https://zimmzones.ddns.net/zm/index.php?view=image&eid=47331&fid=snapshot&username=ESUser&password=*****]
01/25/21 06:34:07 zmesdetect_m11[96245] DBG1 zm_detect.py:294 [No polygon area specfied, so adding a full image polygon:[{'name': 'full_image', 'value': [(0, 0), (640, 0), (640, 480), (0, 480)], 'pattern': '(face|person)'}]]
01/25/21 06:34:07 zmesdetect_m11[96245] DBG1 zm_detect.py:320 [User ALPR if vehicle found: False]
01/25/21 06:34:07 zmesdetect_m11[96245] DBG2 zm_detect.py:372 [using g.config['face_detection_pattern']=.*]
01/25/21 06:34:07 zmesdetect_m11[96245] DBG1 zm_detect.py:405 [Using model: face with /var/lib/zmeventnotification/images/47331-alarm.jpg]
01/25/21 06:34:07 zmesdetect_m11[96245] INF zm_detect.py:46 [Detecting using remote API Gateway http://192.168.17.68:5000/api/v1]
01/25/21 06:34:07 zmesdetect_m11[96245] DBG2 zm_detect.py:54 [Found token file, checking if token has not expired]
01/25/21 06:34:07 zmesdetect_m11[96245] ERR zm_detect.py:414 [Error executing remote API: Extra data: line 1 column 334 (char 333)]
01/25/21 06:34:07 zmesdetect_m11[96245] FAT zm_detect.py:864 [Unrecoverable error:Extra data: line 1 column 334 (char 333) Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 861, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 412, in main_handler
    b, l, c = remote_detect(original_image, model)
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 56, in remote_detect
    data = json.load(json_file)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 334 (char 333)
]

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

Re: Mlapi error when starting detection

Post by asker » Mon Jan 25, 2021 7:24 pm

delete /var/lib/zmeventnotification/zm_login.json
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 29
Joined: Fri Feb 28, 2020 12:25 am

Re: Mlapi error when starting detection

Post by lorenjz » Tue Jan 26, 2021 12:11 am

I think that has got me going and doing what it should be. Again, Thanks a ton for your help!!!!

Post Reply

Who is online

Users browsing this forum: cafftab and 2 guests