This folder contains a complete, end-to-end implementation of a Face Recognition System using Principal Component Analysis (PCA) for dimensionality reduction (Eigenfaces) and Artificial Neural Networks (ANN) for classification.
The project is structured for academic submission and includes:
- A clean, optimized Python implementation (
face_recognition.py) - An academic project report (
report.md) - A presentation outline and viva questions (
presentation_and_viva.md)
- Eigenfaces Generation (PCA): Reduces high-dimensional image data while keeping maximum variance.
-
Neural Network Classification: Uses an
MLPClassifierto map features to distinct identities. -
Accuracy Evaluation: Evaluates and plots the accuracy for different numbers of principal components (
$k$ ). - Imposter Detection: Uses Euclidean distance thresholding to reject unknown faces.
Ensure you have Python installed. Then, install the required dependencies:
pip install numpy opencv-python scikit-learn matplotlib scipyFaceRecognitionProject/
│
├── dataset/ # Directory for your face image dataset
│ ├── person1/
│ │ ├── img1.jpg
│ │ └── img2.jpg
│ └── person2/
│ ├── img1.jpg
│ └── img2.jpg
│
├── results/ # Directory where the accuracy graph will be saved
│
├── face_recognition.py # Main Python script (Object-Oriented)
├── Face_Recognition_Experiment.ipynb # Jupyter Notebook version
├── generate_dummy_dataset.py # Script to capture custom dataset via webcam
├── requirements.txt # Python project dependencies
├── run_project.bat # Executable script to run the project easily (Windows)
├── report.md # Academic project report
├── presentation_and_viva.md # Presentation outline & viva script
└── README.md # Project documentation and instructions
- Double-click the
run_project.batfile. - It will automatically install the necessary libraries and execute the main face recognition script.
- If it tells you the dataset is empty, proceed to step 2 below to capture your face using your webcam.
-
Install Dependencies:
pip install -r requirements.txt
-
Generate a Dataset (Optional but highly recommended for testing): If you don't have images ready, use the built-in webcam script.
python generate_dummy_dataset.py
- Enter your name when prompted.
- Look at your webcam; it will automatically capture 20 face images and save them in
dataset/your_name/. - Run the script again with a friend or different name to build a larger database!
-
Run the Main Script:
python face_recognition.py
(Alternatively, if you prefer an interactive environment, open
Face_Recognition_Experiment.ipynbin Jupyter Notebook.) -
View Results:
- The script will extract Eigenfaces and train the ANN model.
- It will evaluate accuracies across different
$k$ values (number of Eigenfaces) and output the metrics. - Furthermore, it will generate an
accuracy_graph.pnginside theresults/folder visually showing the optimal$k$ value.
-
Testing an Individual Image (Optional): Place an image named
test.jpgin the rootFaceRecognitionProjectfolder alongside the script. When you runface_recognition.py, it will automatically attempt to recognize who it is, or reject the face as an Imposter if not found in the trained database.