This project aims to classify 75 different types of gem images using a neural network model. Given the limited dataset, transfer learning is employed using a pre-trained ResNet50 model. The project is implemented using TensorFlow.
The project consists of two main parts:
- Training: Training the gem classifier model using transfer learning.
- Inference: Using the trained model to classify new gem images.
The training process involves the following steps:
- Examine and Understand the Data: Analyze the dataset to understand its structure and contents.
- Build an Input Pipeline: Prepare the data for training, including data augmentation and batching.
- Compose the Model:
- Load the pre-trained ResNet50 base model.
- Stack the classification layers on top of the base model.
- Train the Model:
- Feature Extraction: Freeze the pre-trained layers and train the new classification layers.
- Fine-Tuning: Unfreeze some of the pre-trained layers and jointly train them with the new layers.
- Evaluate the Model: Assess the performance of the model on the test set.
BATCH_SIZE: 32IMG_SIZE: (224, 224)test_split: 0.1validation_split: 0.1initial_epochs: 300fine_tune_epochs: 2000base_learning_rate: 0.0001
The inference process involves the following steps:
- Load the Model and Class Names:
- Load the pre-trained model using
tf.keras.models.load_model. - Load the class names from a pickle file.
- Load the pre-trained model using
- Process the Image:
- Load and resize the input image to (224, 224).
- Convert the image to a NumPy array and reshape it for model input.
- Make Predictions:
- Use the model to predict the class of the input image.
- Extract the top 5 predictions and their confidence levels.
- Visualize the Results:
- Create a bar plot showing the top 5 predicted classes and their confidence levels.
- Display the input image.
- Ensure you have TensorFlow installed.
- Prepare your dataset and adjust the hyperparameters if necessary.
- Run the
Gem_Classifier_Train.ipynbnotebook to train the model.
- Ensure you have TensorFlow and the necessary dependencies installed.
- Place your input images in the specified directory.
- Run the
Gem_Classifier_Inference.ipynbnotebook to classify new gem images.
- TensorFlow
- NumPy
- Matplotlib
- Pillow
- Pickle