matiasdelellis / facerecognition-external-model

Nextcloud Facerecognition External Model
11 stars 10 forks source link

No Faces Detected #12

Closed JeCheeseSmith closed 6 months ago

JeCheeseSmith commented 6 months ago

Hi!

First of all, thank you and other contributors for maintaining and expanding this functionality! I'm a user of Nextcloud AIO and I'm very glad there is this option now. (I'm unsure if I should post this here or on https://github.com/nextcloud/all-in-one )

I've set up the container and it seems to be running, however, on each image, 0 faces get detected and the nextcloud logs are filled with this error:

Trying to access array offset on value of type null at /var/www/html/custom_apps/facerecognition/lib/Model/ExternalModel/ExternalModel.php#181

The following error is repeatingly showing in the container log: [2024-01-11 18:03:39,598] 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 69, in cnn_detect dets: list = CNN_DETECTOR(img) ^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not callable 172.27.0.7 - - [11/Jan/2024 18:03:39] "POST /detect HTTP/1.1" 500 -

Might I've made a mistake in the installation? Is it a bug?

I use nextcloud as part of my homeserver hobby and I sadly have no experience in this field.

If I can supply any extra information needed, let me know!

matiasdelellis commented 6 months ago

Hi @JeCheeseSmith It seems that the service was restarted for some reason while it is running. See https://github.com/matiasdelellis/facerecognition-external-model/issues/10

Check the container logs. In principle it is fixed on https://github.com/matiasdelellis/facerecognition-external-model/commit/a77a3afdfb4009805c8000962a02f22232a36a72, but I'm interested in knowing why it restarted

szaimen commented 6 months ago

@matiasdelellis maybe the reason is this? https://github.com/nextcloud/all-in-one/blob/f0e206b60d426d19e421d3b57084720314e2017b/community-containers/facerecognition/facerecognition.json#L8

JeCheeseSmith commented 6 months ago

Hi @JeCheeseSmith It seems that the service was restarted for some reason while it is running. See #10

Check the container logs. In principle it is fixed on a77a3af, but I'm interested in knowing why it restarted

Thanks for your fast reply!

Probably a "noob" question, but how do I even specify using the newer image? (If thats possible using the community container of AIO?)

szaimen commented 6 months ago

Probably a "noob" question, but how do I even specify using the newer image? (If thats possible using the community container of AIO?)

If a different image_tag shall be used, it needs to be updated in AIO. That is why I would usually recommend to use an image_tag like latest or e.g. v1 in there. Otherwise the maintainer - @matiasdelellis would always need to update the tag in AIO manually...

matiasdelellis commented 6 months ago

Probably a "noob" question, but how do I even specify using the newer image? (If thats possible using the community container of AIO?)

Soon update my container and the community container to fix this. πŸ˜‰ However, in your case, something restarted the facerecognition-external-model container, while the background_job command within the community container was still running. πŸ€”

If a different image_tag shall be used, it needs to be updated in AIO. That is why I would usually recommend to use an image_tag like latest or e.g. v1 in there. Otherwise the maintainer - @matiasdelellis would always need to update the tag in AIO manually...

Hi @szaimen Of course... I was waiting perhaps for other fixes. There is a new 0.2.0 tag but I did not update the community container because it did not affect its operation.

About the tag name, personally don't like the use of the ":latest" tag, and I prefer to keep a real version in the tags.

szaimen commented 6 months ago

About the tag name, personally don't like the use of the ":latest" tag, and I prefer to keep a real version in the tags.

I see but you will need to do that manually then each time ;)

szaimen commented 6 months ago

My personal recommendation would be to create a tag like v1 and put minor changes into that and if there are major changes you switch to v2, etc.

matiasdelellis commented 6 months ago

My personal recommendation would be to create a tag like v1 and put minor changes into that and if there are major changes you switch to v2, etc.

Great. We agree.. Probably in the afternoon I will update both containers. πŸ˜‰

JeCheeseSmith commented 6 months ago

Soon update my container and the community container to fix this. πŸ˜‰ However, in your case, something restarted the facerecognition-external-model container, while the background_job command within the community container was still running. πŸ€”

I did reran the task mannualy by using the occ face:background_task command since I adjusted some settings (like process shared_folders). Should or shouldn't I do that?

Unsure if this has something to do with it: I use docker-compose which means the nextcloud container stays running, even after I use docker compose down. (The master container goes down) (Unless I stop it mannualy, by using the interface or commmands).

matiasdelellis commented 6 months ago

Ok.. In the last commits I changed our "protocol" to not need to call /open. If the service is restarted (or a container cluster is made), the service works automatically because it initializes the model when necessary. πŸ˜‰

/open is also used to obtain the maximum size and type of the files, and requests are rejected only when these restrictions are not met.

Now I release a new version. Thank you.

szaimen commented 6 months ago

This is now released with v7.11.0 Beta. Testing and feedback is welcome! See https://github.com/nextcloud/all-in-one#how-to-switch-the-channel