This pipeline involves training a binary classification model using transfer learning with a ResNetRS420 base model. Here's a brief overview of the steps involved:
- Image Preprocessing:
- Images are loaded and preprocessed using the preprocess_image function, which resizes the images to the specified dimensions (img_width, img_height) and applies preprocessing suitable for the ResNetRS420 model using tf.keras.applications.inception_v3.preprocess_input.
- Data Preparation:
- The preprocessed images are collected along with their corresponding labels from the training, validation, and test datasets (train_df, val_df, test_df).
- Images are converted to numpy arrays to be fed into the model.
- Base Model Initialization:
- The InceptionV3 model is loaded with the pre-trained ImageNet weights. Only the convolutional base of the model is included (include_top=False) as custom dense layers will be added for classification.
- Model Architecture: Custom classification layers are added on top of the base model:
- LayerNormalization layer to normalize the activations.
- Convolutional layer with 1024 filters and a ReLU activation function.
- MaxPooling layer to downsample the spatial dimensions.
- Dropout layer with a dropout rate of 0.3 to prevent overfitting.
- Flattening layer to convert the 2D feature maps into a 1D vector.
- Dense layer with 512 units and a ReLU activation function.
- Output dense layer with a single unit and a sigmoid activation function for binary classification.
- Model Compilation:
- The model is compiled with the Adam optimizer and binary cross-entropy loss function. Binary accuracy is chosen as the evaluation metric.
- Model Training:
- The model is trained on the training dataset (train_images, train_labels) for 50 epochs.
- Validation data (val_images, val_labels) is provided for monitoring the model's performance during training.
- Monitoring Training Progress:
- The training progress is monitored using the history object returned by the fit method, which contains metrics like loss and accuracy on both training and validation datasets for each epoch.
- Model Evaluation:
- After training, the model's performance can be evaluated on the test dataset
(test_images, test_labels) using appropriate evaluation metrics.
This pipeline leverages transfer learning to utilize the pre-trained InceptionV3 model's feature extraction capabilities while fine-tuning the model for the specific binary classification task. It follows standard practices for training deep learning models, including data preprocessing, model construction, training, and evaluation
Metric | Score |
---|---|
Accuracy | 0.9052 |
Precision | 0.9001 |
Recall | 0.9716 |
F1 Score | 0.9345 |