We focus on developing a deep learning model to classify glomeruli images into two categories: globally sclerotic and non-globally sclerotic. The classification is performed using EfficientNetB3, a powerful convolutional neural network architecture that balances model size and performance.
EfficientNetB3 is chosen due to its balance between accuracy and efficiency. It leverages a compound scaling method that uniformly scales all dimensions of depth, width, and resolution using a set of fixed scaling coefficients. Given the problem statement, EfficientNetB3 allows us to achieve better performance with fewer parameters compared to other architectures.
Images are loaded from specified directories and converted to RGB format.
Images are resized and padded to a uniform size of 300x300 pixels (to satisfy the constraints of EfficientNetB3) while retaining maximum information.
Additional data is generated through transformations including random scaling, translation, and noise addition to prevent overfitting.
Image pixel values are normalized to the range [0, 1] by dividing by 255.
The dataset is split into training and testing sets using stratified sampling to maintain the balance of classes.
Initial training is done with the base EfficientNetB3 layers frozen. Fine-tuning involves unfreezing the top layers and training with a lower learning rate to improve model performance.
The model is evaluated using:
The proportion of correctly classified images.
Binary cross-entropy loss to measure the error in classification.
The ratio of correctly predicted positive observations to the total predicted positives.
The ratio of correctly predicted positive observations to all observations in the actual class.
A confusion matrix provides a detailed breakdown of correct and incorrect predictions for each class.
- TensorFlow
- OpenCV
- NumPy
- h5py
- scikit-learn
- matplotlib
- zipfile
- gc
6.2.1. Method-1: Building Dataset From Scratch, and then using it to train and fine tune the Deep Learning Model, through Google Colab/Kaggle
- Upload the images dataset (Zip file Recommended) in Google Drive to access it in Google Colab/Kaggle if google colab services are not enough.
- Upload the jupyter notebook file(Datagen_b3modeltrain.ipynb) to your Google Colab/Kaggle.
- Follow the cells in the notebook to execute the preprocessing steps, model training, and fine-tuning. a. Import the required libraries. b. Execute the functions to convert images to vectors, resize, and pad them. c. Perform data augmentation and save the processed data into an HDF5 file. d. Load the data from the HDF5 file and normalize it. e. Split the data into training and testing sets. f. Define and compile the EfficientNetB3 model. g. Train the model with frozen layers and save it. h. Unfreeze the top layers, fine-tune the model, and save the final model.
6.3.2. Method-2: Using the pre built dataset (built based on images dataset) directly and Training the deep learning Model
- Upload the Dataset (.h5 file) in Google Drive to access it in google colab/ in kaggle and access it in Kaggle.
- Upload the jupyter notebook fileModel.ipynb to your Google Colab/Kaggle.
- Follow the cells in the notebook to Train the Deep Learning Model.
- Do not forget to download the Trained EfficientNetB3 model and make sure to include it in your working directory while executing evaluation.py. To execute evaluation.py, you can use any IDE/Open source environments like vscode(recommended)/Google Colab/Kaggle.