Skip to content

Commit

Permalink
Fix some spelling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chutrunganh committed Dec 27, 2024
1 parent 5b13246 commit 0dc3a70
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 388 deletions.
6 changes: 3 additions & 3 deletions 1.DataCollection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1219,10 +1219,10 @@
"import os\n",
"\n",
"# Input Path\n",
"video_path = '/home/jawabreh/Desktop/face_scan.MOV'\n",
"video_path = '/home/chutrunganh/Desktop/face_scan.MOV'\n",
"\n",
"# Output Path\n",
"output_dir = '/home/jawabreh/Desktop/face-recognition/training/person_1'\n",
"output_dir = '/home/chutrunganh/Desktop/face-recognition/training/person_1'\n",
"\n",
"# Create the output directory if it doesn't exist\n",
"if not os.path.exists(output_dir):\n",
Expand Down Expand Up @@ -7554,7 +7554,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add your own data as you liek, just put all of them inside the `data` folder. The structure of the data folder should be as follows:\n",
"You can add your own data as you like, just put all of them inside the `data` folder. The structure of the data folder should be as follows:\n",
"\n",
"```plaintext\n",
"data\n",
Expand Down
6 changes: 3 additions & 3 deletions 2.Pipeline2 DataPreprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Preprocessing data for pipeline Siamese network architecture + L1 distance\n",
"\n",
"After this preprocessing step, result in `preprocessed_data(for_Siamese)` folder, we use these data to train a the Siamese network architecture with L1 distance, see in `Siamese_Network.ipynb` notebook."
"After this preprocessing step, result in `preprocessed_data(for_Siamese)` folder, we use these data to train a the Siamese network architecture with L1 distance, see in `3.Pipeline2 Siamese_Network.ipynb` notebook."
]
},
{
Expand Down Expand Up @@ -551,7 +551,7 @@
"The core Siamese network architecture is based on Nicholas Renotte's tutorial series:\n",
"- [Face Recognition with Siamese Networks](https://www.youtube.com/watch?v=bK_k7eebGgc&list=PLgNJO2hghbmhHuhURAGbe6KWpiYZt0AMH)\n",
"\n",
"** Modifications**\n",
"**Modifications**\n",
"The implementation has been adapted to:\n",
"- Handle our own dataset structure\n",
"- Optimize for face verification use case\n",
Expand All @@ -575,7 +575,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions 3.Pipeline1 SVM_Classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"\n",
"After we got extracted face features from `Pipeline1 DataPreprocessing.ipynb` (in form of vector), we have many way to deal with face verifaction problem. Some serveral methods are:\n",
"\n",
"- Compute directly the distance between two face vectors (from a input image when login and the registered images). this way is simple withou any training step, but it is not robust and not general.\n",
"- Compute directly the distance between two face vectors (from a input image when login and the registered images). This way is simple without any training step, but it is not robust and not general.\n",
"\n",
"- Train a classifier model to classify if two vectors are considered as similiar or not (meaning the input img is the same person with the registered image). This way is more robust and general, but it requires a training step. We seen it as a binary classification problem. Given input as a pair of face vectors, the model will output 1 if the two vectors are considered as similiar, and 0 otherwise. Some common models for this problem are SVM, K Nearest Neighbors, Naive Bayes, or even more robust deep learning models.\n",
"- Train a classifier model to classify if two vectors are considered as similiar or not (meaning the input image is the same person with the registered image). This way is more robust and general, but it requires a training step. We seen it as a binary classification problem. Given input as a pair of face vectors, the model will output 1 if the two vectors are considered as similar, and 0 otherwise. Some common models for this problem are SVM, K Nearest Neighbors, Naive Bayes, or even more robust deep learning models.\n",
"\n",
"In this task, we try **SVM (Support Vector Machine)** model to solve the problem.\n",
"\n",
Expand Down Expand Up @@ -459,7 +459,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
14 changes: 8 additions & 6 deletions 3.Pipeline2 Siamese_Network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
"\n",
"- 3: This represents the number of color channels in each image. Typically, 3 channels correspond to the RGB color model (Red, Green, Blue) or BRG color model (Blue, Red, Green).\n",
"\n",
"Each pairs is now coontain an anchor image and a validation image. If the validation image is the same person with the anchor image (call as positive image), the label is 1, otherwise, call as negative image, the label is 0.\n",
"Each pairs is now contain an anchor image and a validation image. If the validation image is the same person with the anchor image (call as positive image), the label is 1, otherwise, call as negative image, the label is 0.\n",
"\n",
"\n",
"Please pay attendtion to the `num_negative_samples` and `num_subfolders_to_sample` parameters. Choose some values that the balance between the positive and negative samples, otherwise, the model will be biased to the negative samples. Or you can use some techinique to balance the dataset, such as oversampling, undersampling, etc."
Expand Down Expand Up @@ -553,13 +553,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Recall th idea, we have two stream of information (we pass in two images: the anchor and the positive/negative image) -> Each stream will pass through an embedding layer to get the feature vector of the image -> Tow feature vectors will be used to calculate the distance between the two images at the Distance layer (here we use L1 distance).\n",
"Recall the idea, we have two stream of information (we pass in two images: the anchor and the positive/negative image) -> Each stream will pass through an embedding layer to get the feature vector of the image -> Tow feature vectors will be used to calculate the distance between the two images at the Distance layer (here we use L1 distance).\n",
"\n",
"\n",
"Here is the Siamese Network architecture we are going to build:\n",
"\n",
"![SiameseStructure](assets/images/SiameseStructure.png)\n",
"\n",
"This netowrk architecture is take from this paper: [Siamese Neural Networks for One-shot Image Recognition](https://www.cs.cmu.edu/~rsalakhu/papers/oneshot1.pdf)\n",
"\n",
"In the paper, it use input size of 105x105, but we will use 100x100 still okey. Therefore, **some numbers may not match exactly to the paper**"
]
},
Expand Down Expand Up @@ -774,7 +776,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Compare two feature vectors to see how similiar our two images are uisng L1 distance (or also called Manhatan distance). The L1 distance is the sum of the absolute differences between the two feature vectors.\n",
"Compare two feature vectors to see how similar our two images are using L1 distance (or also called Manhattan distance). The L1 distance is the sum of the absolute differences between the two feature vectors.\n",
"\n",
"Since there is no L1 distance layer in Keras, we will create a custom layer to calculate the L1 distance. The custom layer will take two feature vectors as input and output the L1 distance between them."
]
Expand Down Expand Up @@ -1108,7 +1110,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this step, we defined actual trainning steps. We train on one batch of data, one batch of data come through our training step, we go on makeing prediction -> calcualte our loss function -> calculate gradient then apply back popagation (calculate new weights and apply) through our neutral network to get the best possible model"
"In this step, we defined actual training steps. We train on one batch of data, one batch of data come through our training step, we go on making prediction -> calculate our loss function -> calculate gradient then apply back propagation (calculate new weights and apply) through our neutral network to get the best possible model"
]
},
{
Expand Down Expand Up @@ -1146,7 +1148,7 @@
" \n",
" # Update the weights\n",
" optimizer.apply_gradients(zip(gradients, fully_siamese_network.trainable_variables))\n",
" # Adam is a variant of stochastic gradient descent, it applies te learning rate and gradient to slightly reduce the loss function, unitll\n",
" # Adam is a variant of stochastic gradient descent, it applies the learning rate and gradient to slightly reduce the loss function, untill\n",
" # it realy near the minimum value.\n",
" \n",
" return loss\n",
Expand Down Expand Up @@ -1990,7 +1992,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions 4.Pipeline1 Application_FaceNet_SVM_CLI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Each device has a different camera IDs/index, so we need to find the correct camera ID for our device. We try to loop throught a range of camera IDs and ask user to check if the camera is working. Each devices can have many webcams, so we have many corresponding camera IDs, we ask user to choose their prefered camera ID as well.\n",
"Each device has a different camera IDs/index, so we need to find the correct camera ID for our device. We try to loop throught a range of camera IDs and ask user to check if the camera is working. Each devices can have many webcams, so we have many corresponding camera IDs, we ask user to choose their preferred camera ID as well.\n",
"\n",
"Store these congifuration to the `application_data/setting.json` file. **Next time, when user open the app, these setting will be loaded without asking user again.**"
"Store these congifuration to the `application_data/settings.json` file. **Next time, when user open the app, these setting will be loaded without asking user again.**"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Developed for the Biometric Course IT4432E (Semester 20241) at HUST, this projec

1. Using a pre-trained Model (**FaceNet**) for features extraction, then use those features to train a **Support Vector Machine** model for classification

2. Training a **Siamese netwrok architecture** + **L1 Distance layer** from scratch
2. Training a **Siamese network architecture** + **L1 Distance layer** from scratch

These approaches combine the convenience and accuracy of pre-trained models with the educational value of
training custom architectures from scratch. After training, we obtain models and use them to build applications with GUI using **PyQT6** and **Kivy** framework.
Expand Down
Loading

0 comments on commit 0dc3a70

Please sign in to comment.