Ship_Detection

🚒 Ship Detection (Final Milestone)

VITMAV45 – Deep Learning in Practice with Python and LUA

Major Term Project – Airbus Ship Detection Challenge (Kaggle)

MegajΓ‘nlott jegyΓ©rt!


πŸ“˜ Project Overview

This repository contains our final solution for the Deep Learning in Practice course. Our project tackles the Airbus Ship Detection Challenge on Kaggle, focusing on detecting ships in satellite images using a robust Two-Stage Deep Learning Pipeline.

In addition to the research notebooks, we have deployed the model as a Full-Stack Web Application allowing users to upload satellite images and receive real-time detection overlays.


🎯 Key Objectives & Achievements


πŸ‘₯ Team Information

Team Name: 99_Problems_but_a_Batch_Aint_One

Name Neptun Code Role
Bologa Eduard DAM4AV Documentation, GitHub integration, pipeline architecture design, final report
Kozma Szabolcs AndrΓ‘s TKGQWN Data loading optimization, loss function tuning (Tversky), metric implementation
PΓΌnkΓΆsti GyΓΆrk VCV3N5 Model training (Classifier & Segmenter), inference pipeline, visualizations, Dockerization

🧠 The Solution: Two-Stage Pipeline

Due to the extreme class imbalance (most satellite images contain only sea), a single segmentation model often produces false positives (β€œghost ships”) on waves or clouds. We solved this with a two-step approach:

1. Stage 1: The Classifier (Filter)

2. Stage 2: The Segmenter (Pixel-Level Detection)


πŸš€ Optimization & Results

We implemented several key optimizations to improve performance and training speed:

πŸ“Š Final Performance (Test Set)

Metric Score Description
F2 Score 0.8977 (Primary Metric) Harmonic mean of precision and recall, weighing recall higher.
Precision 81.58% Percentage of predicted ships that are actually ships.
Recall 92.08% Percentage of real ships that were successfully detected.

πŸ’» How to Run the Web App

We have containerized the application using Docker for easy deployment.

Prerequisites

Quick Start

  1. Clone the repository:
    git clone https://github.com/99ProblemsButABatchAint1/Ship_Detection.git
    cd Ship_Detection
    
    
  2. Add Model Weights:
    • Note: Large model files are ignored by git.
    • Manually copy your .pth files into the backend/models/ directory.
  3. Run with Docker Compose:
    docker compose up --build
    

    (Note: If you run into network errors on University WiFi/VPN, try disconnecting the VPN or setting the MTU in Docker settings to 1300).

  4. Access the App:

πŸ“‚ Repository Structure

β”œβ”€β”€ LICENSE
β”œβ”€β”€ notebooks
β”‚Β Β  β”œβ”€β”€ milestone1.ipynb
β”‚Β Β  β”œβ”€β”€ milestone2.ipynb
β”‚Β Β  β”œβ”€β”€ milestone.ipynb
β”‚Β Β  β”œβ”€β”€ notebook.ipynb
β”‚Β Β  β”œβ”€β”€ ship_detection_work_notebook
β”‚Β Β  β”œβ”€β”€ ship_detection_work_notebook.ipynb
β”‚Β Β  └── unet_ship_detection.pth
β”œβ”€β”€ project
β”‚Β Β  β”œβ”€β”€ backend
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ app
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ deps.py
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ main.py
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __pycache__
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ deps.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── main.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ routes
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ detect.py
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ health.py
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── __pycache__
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ detect.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β      └── health.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── services
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ detector.py
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ detector_stub.py
β”‚Β Β  β”‚Β Β  β”‚Β Β      └── __pycache__
β”‚Β Β  β”‚Β Β  β”‚Β Β          β”œβ”€β”€ detector.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”‚Β Β          └── detector_stub.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Dockerfile
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ models
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ best_classifier.pth
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── best_ship_segmenter.pth
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __pycache__
β”‚Β Β  β”‚Β Β  └── requirements
β”‚Β Β  β”œβ”€β”€ docker-compose.yml
β”‚Β Β  β”œβ”€β”€ Dockerfile.dev
β”‚Β Β  β”œβ”€β”€ eslint.config.js
β”‚Β Β  β”œβ”€β”€ index.html
β”‚Β Β  β”œβ”€β”€ package.json
β”‚Β Β  β”œβ”€β”€ package-lock.json
β”‚Β Β  β”œβ”€β”€ public
β”‚Β Β  β”‚Β Β  └── vite.svg
β”œβ”€β”€ README.md
β”œβ”€β”€ final_milestone_documentation.pdf
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ best_classifier.pth
β”‚Β Β  β”œβ”€β”€ best_ship_segmenter.pth
β”‚Β Β  β”œβ”€β”€ dataset.py
β”‚Β Β  β”œβ”€β”€ inference.py
β”‚Β Β  β”œβ”€β”€ losses.py
β”‚Β Β  β”œβ”€β”€ metrics.py
β”‚Β Β  β”œβ”€β”€ model.py
β”‚Β Β  β”œβ”€β”€ __pycache__
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ dataset.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ losses.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ metrics.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ model.cpython-313.pyc
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ rle.cpython-313.pyc
β”‚Β Β  β”‚Β Β  └── transforms.cpython-313.pyc
β”‚Β Β  β”œβ”€β”€ rle.py
β”‚Β Β  β”œβ”€β”€ train.py
β”‚Β Β  β”œβ”€β”€ transforms.py
β”‚Β Β  └── tune_thresholds.py
β”œβ”€β”€ unet_ship_detection.pth
└── weights
    β”œβ”€β”€ best_classifier.pth
    └── best_ship_segmenter.pth

Open In Colab