This repository contains code for a deep learning model built with TensorFlow and Keras for detecting glasses on human faces in images.
The project is structured into several sections:
-
Data Cleaning: The dataset is prepared, including converting images from PNG to JPG format and examining the dataset for quality issues.
-
Data Processing: The dataset is split into training, validation, and test sets. Data augmentation techniques are applied to increase the dataset size and improve model generalization.
-
Preparing Base Model: Transfer learning is used with the MobileNetV2 architecture as the base model. The base model is modified by adding custom classification layers.
-
Training the Model: The model is compiled and trained on the dataset. Both training and validation accuracies and losses are monitored.
-
Fine-Tuning: After initial training, the top layers of the base model are unfrozen, and the entire model is fine-tuned to improve performance further.
-
Prediction: The trained model makes predictions on unseen test data. Sample predictions are visualized along with the corresponding images.
-
Convert to TFLite: The trained model is converted to TensorFlow Lite format for deployment on resource-constrained devices.
-
Debugging: A debugging code is included to verify the functionality of the TensorFlow Lite model.
To use this code for glass detection on human faces, follow these steps:
-
Ensure all necessary dependencies are installed. This includes TensorFlow, Keras, Matplotlib, NumPy, and other libraries used in the code.
-
Prepare your dataset or use the provided dataset. Ensure that the dataset is structured correctly with appropriate class labels.
-
Modify the paths and parameters in the code to fit your dataset and requirements.
-
Run each code section sequentially, monitoring outputs and visualizations for insights.
-
Evaluate the model's performance on test data and fine-tune parameters as needed.
-
Convert the trained model to TensorFlow Lite format if deployment on mobile or edge devices is required.
-
Use the TensorFlow Lite model for inference on target devices.
This project is adapted from the TensorFlow tutorials on transfer learning and fine-tuning.
This project is licensed under the MIT License.