Skip to content

JuFrei/ShipPred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ship Detection from Orbit

This repository contains code for training and comparing two models for ship detection in satellite imagery: a Convolutional Neural Network (CNN) implemented in PyTorch and a Support Vector Machine (SVM) classifier using Histogram of Oriented Gradient (HOG) features.

Data

Source

https://www.kaggle.com/datasets/rhammell/ships-in-satellite-imagery

Description

The dataset comprises 4000 RGB images, each sized 80x80 pixels, extracted from Planet satellite imagery covering the San Francisco Bay and San Pedro Bay regions of California. These images are classified as either "ship" or "no-ship".

Labels

The dataset comprises two classes:

  • "Ship" Class: This class consists of 1000 images, each centered on the body of a single ship. ship img

  • "No-Ship" Class: This class comprises 3000 images. A third of the images representing various land cover features such as water bodies, vegetation, bare earth, and buildings, without any portion of a ship. Another third containing "partial ships" that show only a portion of a ship. The final third consists of images previously mislabeled by machine learning models. nonship img

Data Splitting

The dataset is split into three sets: training, validation, and test sets. The splitting ratio is 70% for training, 20% for validation, and 10% for testing.

Convolutional Neural Network (CNN) Architecture

The CNN architecture consists of convolutional layers followed by max-pooling layers and fully connected layers, designed to classify input images into two classes.

Model Architecture

  • Input Layer: Accepts input images with three channels (RGB).

  • Convolutional Layers: Two convolutional layers with ReLU activation functions followed by batch normalization and max-pooling layers.

  • Fully Connected Layers: Two fully connected layers with ReLU activation functions, followed by a dropout layer to prevent overfitting.

  • Output Layer: A single neuron with a sigmoid activation function for binary classification.

Chosen Hyperparameters

  • batch_size = 8

  • num_epochs = 100

  • learning_rate = 0.0001

  • momentum = 0.9

  • early_stopping_patience = 10

Training and Evaluation

  • The code provides functions for training the CNN and evaluating its performance on validation and test sets.
  • Training includes monitoring loss and accuracy metrics, with early stopping implemented to prevent overfitting.
  • Model hyperparameters such as batch size, learning rate, and momentum are adjustable.
  • After training, the code evaluates the model's accuracy and generates plots for visualization, including training/validation accuracy and loss curves and a confusion matrix.

Val Test Loss Val Test Acc

Support Vector Machine (SVM) Model

For the SVM model, Histogram of Oriented Gradients (HOG) features are extracted from the grayscale satellite images.

Model Training

After extracting HOG features from the grayscale satellite images, the SVM model is trained using these features as input. The SVM algorithm aims to find the optimal hyperplane that separates the feature space into different classes (ships and non-ships) while maximizing the margin between the classes.

Hyperparameter Tuning

To optimize the performance of the SVM model, hyperparameters such as the regularization parameter (C) and kernel function type are tuned using grid search. The models where created from combinations of C (0.1, 1, 3, 5, 7, 10, 25) and kernel (linear, rbf, poly).

Chosen Hyperparameters

  • C: 5
  • kernel: rbf

Model Comparison

The performance of the SVM model is compared with that of the Convolutional Neural Network (CNN) model trained on the same dataset using the various metrics and the confusion matrices. Both models achieve an accuracy of 99.24%.

ConvNet Confusion Matrix

SVM Confusion Matrix

Convnet Misclassified Images

ConvNet Misclassified

SVM Misclassified Images

SVM Misclassified

Result Interpretation

The Convolutional Neural Network (CNN) and Support Vector Machine (SVM) models both perform well in ship detection, achieving an accuracy of 99.24%. This high accuracy demonstrates their effectiveness in distinguishing between ship and non-ship objects in satellite imagery. The confusion matrices reveal a notable distinction between the two models. The CNN model incorrectly classified three ships as non-ships, while it had no false positives. On the other hand, the SVM model had three false positives, where non-ship objects were classified as ships, but no false negatives occurred.

The Support Vector Machine (SVM) tends to misclassify non-ship objects that have visual similarities with ships or ambiguous features. On the other hand, the Convolutional Neural Network (CNN) might misclassify ships due to similar background coloration.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published