This face recognition project involves collecting images, generating embeddings, performing clustering, and running a real-time face recognition application. Follow the steps below to set up and run the project.
Creating a virtual environment is recommended to manage dependencies.
python -m venv venv
Activate the virtual environment. The activation command varies depending on your operating system.
-
On Windows:
.\venv\Scripts\activate
-
On Unix or MacOS:
source venv/bin/activate
Install all required Python packages.
pip install -r requirements.txt
Run the main application script.
python main.py
Use the application to collect images. When you run main.py
, it starts a server that you can interact with through a web interface.
- Navigate to the web interface and use the 'Save Image' button to collect images for the first person.
- The images are saved in a specified directory.
After collecting enough images for the first person, stop the application. Change the directory name in the code where images are being saved to start collecting images for the second person.
Restart the application and collect images for the second person using the same 'Save Image' button.
Once you have collected enough images for both individuals:
This script will process the collected images and generate embeddings.
python create_embeddings.py
After generating embeddings:
This script applies K-means clustering to the embeddings.
python k_means_clustering.py
Finally, run main.py
again.
python main.py
Now, the application should be able to recognize faces in real-time and display names next to the detected faces based on the clusters.
- Ensure all scripts (
main.py
,create_embeddings.py
,k_means_clustering.py
) are in the project directory. - Adjust any file paths or configurations in the scripts as necessary for your setup.