AI Faces - Insightface plugin

84 views
Skip to first unread message

Jim Kirkpatrick

unread,
Jun 6, 2025, 10:32:25 PM6/6/25
to ResourceSpace
I managed to get this installed under Ubuntu 24.04. It was a struggle as the install instructions are a bit basic and have you installing the application files in your home directory rather than a normal system directory. Once I was able to get it running, the plugins/faces/scripts/php faces_detect.php script ran and detected faces in all 86,000 images on our system. So far, so good. The faces show up and I can tag them with names.

When I ran the plugins/faces/scripts/php faces_tag.php script it began returning "Error from faces_service (HTTP 500)" messages for each file examined. Likewise clicking the Find matching faces link in any detected face returns the same error.

Http 500 is a generic error message, given when an unexpected condition was encountered and no more specific message is suitable. There's no corresponding messages in the Apache2 error log.

I'd appreciate any suggestions on how one might troubleshoot this.

Jim Kirkpatrick

Dan Huby

unread,
Jun 7, 2025, 5:39:52 PM6/7/25
to ResourceSpace
Hi Jim,

Presumably the Python server is still running? Any issues should show up on the console there, if you're running it from the command line (advisable for testing).

Dan

Jim Kirkpatrick

unread,
Jun 7, 2025, 8:06:36 PM6/7/25
to resour...@googlegroups.com
Dan,

Thank you for responding. I rebooted our server and re-ran the service from the command line. 

Confession: I can follow instructions but am not understanding the python environment creation. The venv seems unaware of python modules installed on our server and require them to be installed within the virtual environment before the service will run. 

That said, here is the output produced when I tried using the Find matching faces function. 

INFO:     Started server process [6240]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
INFO:     127.0.0.1:37196 - "POST /find_similar_faces HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app(  # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__
await self.app(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__
await self.middleware_stack(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/routing.py", line 734, in app
await route.handle(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
  ^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/resourcespace/plugins/faces/scripts/faces_service.py", line 143, in find_similar_faces
load_vectors(db_name)
  File "/var/www/html/resourcespace/plugins/faces/scripts/faces_service.py", line 52, in load_vectors
conn = get_mysql_connection(db_name)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/resourcespace/plugins/faces/scripts/faces_service.py", line 43, in get_mysql_connection
return mysql.connector.connect(
  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/pooling.py", line 323, in connect
return MySQLConnection(*args, **kwargs)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/connection.py", line 185, in __init__
self.connect(**kwargs)
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1605, in connect
self._open_connection()
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/connection.py", line 411, in _open_connection
raise err
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/connection.py", line 388, in _open_connection
self._do_auth(
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/connection.py", line 320, in _do_auth
ok_pkt = self._authenticator.authenticate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/authentication.py", line 381, in authenticate
ok_pkt = self._handle_server_response(sock, pkt)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/html/RS_AI/facenv/lib/python3.12/site-packages/mysql/connector/authentication.py", line 287, in _handle_server_response
raise get_exception(pkt)
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'resourcespace_rw'@'localhost' (using password: YES)


--
ResourceSpace: Open Source Digital Asset Management
http://www.resourcespace.com
---
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resourcespac...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/resourcespace/cc797a44-846e-4c5d-bb9f-92c7f856cc58n%40googlegroups.com.

Dan Huby

unread,
Jun 7, 2025, 11:03:02 PM6/7/25
to ResourceSpace
The python service is failing to connect to your database using the credentials supplied when you started the service.

These aren't needed to index faces but are needed for the face search, which explains what you're seeing.

I hope that points you in the right direction.

Dan

Jim Kirkpatrick

unread,
Jun 8, 2025, 12:12:47 AM6/8/25
to resour...@googlegroups.com
Dan,

Thank you for replying so quickly. I’ve checked several times to insure that the  string used to start the service is correct. I’ve obfuscated the password here but it is the same in my config.php and the command line args.

python3 -m faces_service --db-host=localhost --db-user=resourcespace_rw --db-pass=[password]

Our config.php lists:

$mysql_server = 'localhost';
$mysql_username = 'resourcespace_rw';
$mysql_password = [password];
$mysql_db = 'RSDB’;

Is it possible that the service is assuming the DB name is resourcespace? resourcespace/plugins/faces/scripts/faces_service.py has an argument ‘db_name' but I don’t see where that is defined.

Jim



You received this message because you are subscribed to a topic in the Google Groups "ResourceSpace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/resourcespace/nszGfJG9j1g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to resourcespac...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/resourcespace/c41362da-344c-44a7-b0c8-0bdb4069c702n%40googlegroups.com.

Dan Huby

unread,
Jun 8, 2025, 2:36:25 AM6/8/25
to ResourceSpace
It might be that the password needs to be quoted and/or escaped - obviously I can't see it to let you know if that's the case. If it's not just alphanumeric it's likely you do.

You don't need to worry about the database name - this is sent via the API from ResourceSpace as part of each request.

Once this is working you could set up a new database user just for the service that has read only access to the resource_face table only, as an additional security measure. The Python service needs no more than that.

Dan

Jim Kirkpatrick

unread,
Jun 8, 2025, 1:14:16 PM6/8/25
to resour...@googlegroups.com
Dan,

Thank you for pointing out what I had missed, a character in the password that needed to be escaped. It’s one of those times when you stare a something so long you no longer see the glaring error. faces_tag.php is merrily tagging as I write.

It will be a big help to have this functionality. I’d been doing it externally using the recognition engine in Adobe Lightroom, an extra step I can now retire.

Jim

Marc

unread,
Jun 12, 2025, 3:59:37 PM6/12/25
to ResourceSpace
How did you get the plugin installed? I'm following the instructions (AI Faces (InsightFace) | ResourceSpace) but when I get to step 5 I get a no such file or directory error for faces_service.py.

Stuart Ball

unread,
Jun 12, 2025, 6:03:11 PM6/12/25
to ResourceSpace
I was struggling with the connection details in the serviceD setup, once I put the password in quotes worked straight away,

It's bloody amazing plugin. We're using it as a digital archive of our sea cadet unit, so we have lots of faces, some of which have consent to publish some not. This will make it a much easier to restrict access to those photos of particular young people when it comes to sharing.

Thank you so much.

Stuart
Milton Keynes Sea Cadets

Jim Kirkpatrick

unread,
Jun 12, 2025, 6:12:05 PM6/12/25
to resour...@googlegroups.com
It’s in the same folder as the two PHP scripts:

resourcespace/plugins/faces/scripts

You either run it from there or give it a path. 

Jim

--
ResourceSpace: Open Source Digital Asset Management
http://www.resourcespace.com
---
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resourcespac...@googlegroups.com.

Marc

unread,
Jun 12, 2025, 6:16:50 PM6/12/25
to ResourceSpace
Interesting... I'm running the latest version of RS and I don't have that plugin/folder.

Jim Kirkpatrick

unread,
Jun 12, 2025, 6:23:29 PM6/12/25
to resour...@googlegroups.com
Have you actually enabled the plugin via system > plugins?

Jim

Marc

unread,
Jun 13, 2025, 12:08:53 PM6/13/25
to ResourceSpace
It turns out several files were missing. Re-running svn to upgrade fixed the issue.
Reply all
Reply to author
Forward
0 new messages