matiasdelellis / facerecognition-external-model

Nextcloud Facerecognition External Model
11 stars 10 forks source link

Docker restart leads to errors #10

Closed tomhub closed 6 months ago

tomhub commented 8 months ago

I was running occ face:background_job on nextcloud server, and face detection on separate server. During this process, I restarted remote face detection server and expected continuation of background_job detection. However, this led to these errors:

XXX.XXX.XXX.XXX - - [09/Nov/2023 07:08:54] "POST /detect HTTP/1.1" 500 -
[2023-11-09 07:08:58,550] ERROR in app: Exception on /detect [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/facerecognition-external-model.py", line 60, in decorated_function
    return view_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/facerecognition-external-model.py", line 148, in detect_faces
    faces = DETECT_FACES_FUNCTIONS[FACE_MODEL](img)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/facerecognition-external-model.py", line 116, in cnn_hog_detect
    cnn_faces = cnn_detect(img)
                ^^^^^^^^^^^^^^^
  File "/app/facerecognition-external-model.py", line 69, in cnn_detect
    dets: list = CNN_DETECTOR(img)
                 ^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

I did not know how to resolve this, but I went into in nextcloud admin panel, face recognition menu, and the process seems to have properly started to work again:

....
TypeError: 'NoneType' object is not callable
XXX.XXX.XXX.XXX - - [09/Nov/2023 08:14:13] "POST /detect HTTP/1.1" 500 -
XXX.XXX.XXX.XXX - - [09/Nov/2023 08:14:17] "GET /open HTTP/1.1" 200 -
XXX.XXX.XXX.XXX - - [09/Nov/2023 08:14:35] "POST /detect HTTP/1.1" 200 -
XXX.XXX.XXX.XXX - - [09/Nov/2023 08:14:58] "POST /detect HTTP/1.1" 200 -
...
matiasdelellis commented 6 months ago

Practically fixed in the last commit.. It doesn't continue working because our protocol indicates that always have to call /open before using it, but at least now only responds with an http status code 412.

On the face recognition application side, it will just ignore these images, and try to analyze them on the next run again..

Thanks for the report. 😄