Page 1 of 1

Exchange on Face recognition and Face comparison

Posted: Mon Mar 10, 2025 2:19 pm
by dige
Hi folks,

I would like to build a face recognition system with OpenCV or Python / dlib.

Than determine the vectors (embeddings) of the recognized faces and save them in a vectore database like chromaDB.
And thus have the possibility to compare faces e.g. with Cosine Similarity.

In other words, in the same way that https://facecheck.id/ is breathtakingly fast and effective.

This is what ChatGPT suggested to me.

Now my actual question: who is already familiar with this area? How would you do it?
In the forum there are already codes to recognize faces via the Windows API or from JHP JHP a face recognition with OpenCV.
How would you determine the face vectors?
Is it a good idea to do the whole thing using RunProgram() and Python?

I appreciate any tips! Thanks!!!

Ciao Dige

Re: Exchange on Face recognition and Face comparison

Posted: Mon Mar 10, 2025 9:33 pm
by Sergey
Yes, you're may run deepface on Python
https://github.com/serengil/deepface
Last released on Aug 17, 2024

Works well, every model about 500 MB (gender, race, age)
And maybe anybody transfer this project to PB once

Re: Exchange on Face recognition and Face comparison

Posted: Tue Mar 11, 2025 8:44 am
by dige
Thank you Sergey, Deepface looks very promising. Let's see if I can get it to run on Windows.

Re: Exchange on Face recognition and Face comparison

Posted: Tue Mar 11, 2025 10:04 am
by dige
-Update-

Wow, that's fantastic!
Recognizing faces, age, emotion etc. works very well.

If you want to try it out (under Windows).
I have Python 3.12. Python installed -> https://www.python.org/downloads/
Make sure you select “Add Python to PATH” when installing!

Open a command prompt (CMD) or PowerShell and create a virtual environment:

python -m venv deepface_env
cd deepface_env
Scripts\activate

DeepFace requires some Python libraries. Install them with:
pip install deepface

I then had to install tf_keras manually:
pip install tf-keras

Now try out Deepface
Start Python

from deepface import DeepFace

result = DeepFace.analyze(“C:\\temp\\test.jpg”, actions=['age', 'gender', 'emotion', 'race'])
print(result)

Next I will try to encapsulate this with PureBasic and process the recognized faces and their characteristics

Re: Exchange on Face recognition and Face comparison

Posted: Tue Mar 11, 2025 11:33 am
by Caronte3D
dige wrote: Tue Mar 11, 2025 10:04 am Next I will try to encapsulate this with PureBasic and process the recognized faces and their characteristics
This would be fantastic! :D

Re: Exchange on Face recognition and Face comparison

Posted: Tue Mar 11, 2025 5:25 pm
by Sergey
dige wrote: Tue Mar 11, 2025 10:04 am Wow, that's fantastic!
Recognizing faces, age, emotion etc. works very well.
I knew that you would like it
It also very simple to use
And it has many face detectors, try each of them

I wish you success in the adaptation of DeepFace on Purebasic 8)

Re: Exchange on Face recognition and Face comparison

Posted: Fri Mar 14, 2025 2:55 pm
by dige
Dropping a quick update:

Got some solid progress:

✅ Importing an entire image directory
✅ Extracting faces
✅ Analyzing age, emotions, race & generating embeddings

💾 Embeddings are stored in ChromaDB
🔍 Face search now works – can find faces & measure similarity

So far, everything's still running purely in Python and its very slow :|

⚡ Next step: PureBasic will handle everything on a meta level.

Re: Exchange on Face recognition and Face comparison

Posted: Fri Mar 14, 2025 5:15 pm
by miso
I'm not a lawyer, but detecting emotions with an AI is restricted by a brand new EU AI Act. I think. I'm not a lawyer.

Re: Exchange on Face recognition and Face comparison

Posted: Fri Mar 14, 2025 6:10 pm
by dige
You are right, but its ok for private use