This repository contains code and models for ship detection in satellite images using deep learning-based semantic segmentation. It leverages a cleaned and preprocessed subset of the Airbus Ship Detection dataset. After preprocessing and cleaning, a subset of 12,788 images is obtained, which is then cached into local storage for faster lookup when training the model.
Download the subset of 12,788 cleaned and preprocessed images from Google Drive and place them in some folder.
Note: In case we wanted to start to train the models, we would need to first generate the cached images and masks, by also downloading the cleaned
masks_subset.csvfile from Google Drive (or project folder), updating the 4 path variables at the beginning of the file 'preprocessing/build_cache.py', and running it as:
python preprocessing/build_cache.pyNote that, currently, this notebook already has some test set image examples saved in the folder images within the current directory. However, one can also make it work for any image on the test set by doing the following:
- Download the test set of 15,606 images from Google Drive
- In cell 4 within the notebook, set the variable
TEST_DIRto the path where these images were saved, and uncomment the lines stated in the notebook.
Our best model is the finetuned_model_512.tflite and exists in the repo, you can also find other models in our Google Drive, if you wish to use them for inference, you will need to convert them using lighter_model.py, this will convert the .keras to .tflite, which makes the model faster for inference and adapted to our script.
README.md– Project documentation and setup instructionsrequirements.txt– Python package dependencies if you use pipenvironment.yaml– Python package dependencies for Macenvironment_windows.yaml– Python package dependencies for Windowsmasks_subset.csv– CSV file containing ship mask annotations for the cleaned subsetinference.ipynb– Jupyter notebook for running inference on test images using trained models
Contains scripts and notebooks for data preprocessing and exploration:
build_cache.py– Generates cached images and masks for faster traininghelpers.py– Utility functions for preprocessingdataprocessing.ipynb– Data processing exploration and workflowimage_creation.ipynb– Image preparation and augmentationeda-of-the-dataset.ipynb– Exploratory Data Analysischeck_images.ipynb– Image validation and quality checksold_explorations/– Archive of earlier exploration notebooks
Core training scripts for different model architectures:
FINAL_MODEL.py– Final optimized model training scriptResNet34.py– ResNet34-based semantic segmentation modelResNet101.py– ResNet101-based semantic segmentation modelUNet.py– U-Net based semantic segmentation modelnpy_generator.py– Data generator for training from numpy arrays
Post-training optimization and inference scripts:
postprocessing.py– Post-processing pipeline for model predictionssubmission_parallel.py– Parallel inference for generating submission filessubmission_512.py– Submission script optimized for 512-pixel imagesfinetuning.py– Fine-tuning script for model improvementslighter_model.py– Model optimization for reduced size/inference timedebug_model.py– Debugging utilities for model analysisdebug_model_big.py– Extended debugging utilities
Trained model files:
final_model.tflite– Final optimized TensorFlow Lite modelfinetuned_model_512.tflite– Fine-tuned model for 512-pixel inputs
Training results and visualizations:
initial_train/– Results from initial model trainingtraining_metrics.csv– Initial training metrics
finetuning/– Results from fine-tuning experimentstraining_metrics.csv– Fine-tuning metrics
visual_debug_50/– Visual debugging outputs (50 samples)visual_debug_old_50/– Archive of older visual debugging outputs
Final submission files for competitions/evaluations:
resnet34.csv– ResNet34 predictionsresnet34FN.csv– ResNet34 with false negative handlingresnet34_FN+filtered.csv– ResNet34 with filtered false negativesresnet101.csv– ResNet101 predictionsunet.csv– U-Net predictions
Scripts for distributed/cluster computing:
run.sh– Main cluster execution scriptrun2.sh– Alternative cluster execution variantrun3.sh– Another cluster execution variant
Logging utilities:
log_processing.py– Script for processing and analyzing logs
Test images for inference demonstrations