This project uses Convolutional Neural Networks (CNNs) to classify satellite images into different categories. The dataset consists of satellite imagery, and the model is trained to differentiate between various classes using data augmentation, multiple layers of CNNs, and modern deep learning techniques.
We are using a Satellite Image Classification dataset, which can be downloaded from Kaggle using the following link:
Kaggle Dataset: Satellite Image Classification 🌐
The dataset contains satellite images stored in directories, representing different categories (for example, agricultural, forest, etc.).
Before running the code, you need to have the following packages installed:
keras
tensorflow
numpy
matplotlib
You can install the necessary libraries using the following command:
pip install keras tensorflow numpy matplotlib
To download the dataset from Kaggle, follow these steps:
- Upload your
kaggle.json
API key. - Use the following command to download the dataset:
!kaggle datasets download -d mahmoudreda55/satellite-image-classification
After downloading, unzip the dataset to access the images for training and validation.
The model used in this project is a sequential CNN with multiple layers:
- Input Layer: The model accepts images of size 224x224x3 (height, width, color channels).
- Convolution Layers: We use 4 convolutional layers with filters of increasing depth (32, 64, 128, 256), and ReLU activation functions.
- Pooling Layers: MaxPooling layers are added to downsample the feature maps.
- Dropout: To prevent overfitting, a 40% dropout is applied before the output layer.
- Global Average Pooling: Replaces flattening for dimensionality reduction.
- Output Layer: A softmax layer with 4 units for multi-class classification.
The training images undergo various transformations to enhance model generalization:
- Horizontal and vertical flips
- Shearing
- Zooming
- Shifting
These transformations help in creating a more robust model that can handle a variety of satellite imagery variations.
The model is compiled using the Adam optimizer with a learning rate of 0.0001 and categorical cross-entropy as the loss function.
model.compile(optimizer=optimizer,
loss='categorical_crossentropy',
metrics=metrics)
We use early stopping to monitor validation loss and stop training once the performance starts to degrade.
early_stopping = EarlyStopping(monitor='val_loss', patience=15, restore_best_weights=True)
The training process is set to run for 30 epochs with the option to stop early.
After training, the model is evaluated on the validation data. Key metrics used are:
- Accuracy: Measures the percentage of correct predictions.
- AUC (Area Under the Curve): Evaluates the model’s ability to differentiate between classes.
val_loss, val_accuracy, val_auc = model.evaluate(validation_generator, verbose=0)
We plot the training and validation loss and accuracy to understand the model's performance over epochs.
plt.plot(history.history['loss'], label='Training Loss')
plt.plot(history.history['val_loss'], label='Validation Loss')
In addition to training a CNN from scratch, we fine-tune a NASNetMobile pretrained model. The top layers are retrained on the satellite image dataset, with the lower layers frozen to retain learned features from the ImageNet dataset.
After training, the model is evaluated on accuracy, loss, and AUC. The model can be further fine-tuned to improve performance using techniques like data augmentation, learning rate scheduling, and transfer learning.
- Prepare your environment: Make sure you have all necessary libraries installed.
- Download the dataset: Use the provided Kaggle API link to download the dataset.
- Run the training code: Execute the training process and monitor the output for model performance.
- Evaluate and plot results: Use the plotting functions to visualize the training performance.
- Experiment with different architectures like ResNet, VGG16, and EfficientNet.
- Try out hyperparameter tuning for improved performance.
- Implement Grad-CAM to visualize which parts of the image contribute to the classification decision.
This project is licensed under the MIT License.