Skip to content

πŸ“‘ Production-grade maritime surveillance system for detecting ships in Synthetic Aperture Radar (SAR) imagery using YOLOv8-OBB (Oriented Bounding Boxes) and Lee speckle filtering. Handles the unique challenges of radar imagery: multiplicative noise and arbitrarily-oriented vessels.

License

Notifications You must be signed in to change notification settings

kbhujbal/Trident-synthetic_aperture_radar_maritime_vessel_detection_yolov8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Trident - SAR Maritime Vessel Detection

A production-grade maritime surveillance system for detecting ships in Synthetic Aperture Radar (SAR) imagery using Oriented Bounding Boxes (OBB) and speckle noise filtering.

Detection Results

Mission

Detect ships in SAR images where vessels appear as noisy "salt-and-pepper" clusters, using:

  • Lee Speckle Filter: Remove radar-specific multiplicative noise
  • YOLOv8-OBB: Detect ships with rotated bounding boxes (ships are rarely horizontal)

Pipeline

Pipeline

Why This Approach?

The SAR Challenge

SAR images suffer from "speckle noise" - a granular interference pattern unique to coherent radar imaging. Ships appear as bright clusters mixed with noise, making standard detection difficult.

Speckle Filtering (The "Secret Sauce")

Speckle Filter Comparison

The Lee filter removes multiplicative radar noise while preserving ship edges:

Before Lee Filter:          After Lee Filter:
β–‘β–‘β–ˆβ–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–ˆβ–‘β–‘           β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
β–‘β–ˆβ–‘β–ˆβ–‘β–ˆβ–‘β–‘β–‘β–ˆβ–‘β–ˆβ–‘β–‘β–‘β–‘           β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘
β–‘β–‘β–ˆβ–‘β–‘β–‘β–ˆβ–‘β–ˆβ–‘β–‘β–ˆβ–‘β–‘β–‘β–‘    β†’      β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘
β–‘β–ˆβ–‘β–ˆβ–‘β–‘β–‘β–ˆβ–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘           β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘
β–‘β–‘β–‘β–ˆβ–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘           β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘

Why Oriented Bounding Boxes?

Ships sail in arbitrary directions. Axis-aligned boxes waste pixels and overlap:

Standard Box (AABB):        Oriented Box (OBB):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β•±β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•²
β”‚  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ       β”‚           β•±β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•²
β”‚       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β”‚    β†’       β•²β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•±
β”‚           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚            β•²β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•±
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  60% background!              Tight fit!

Sample Detection Results

Single Ship Multiple Ships Complex Scene

Project Structure

Trident/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py          # Package initialization
β”‚   β”œβ”€β”€ data_manager.py      # Kaggle download, COCOβ†’YOLO conversion
β”‚   β”œβ”€β”€ preprocessing.py     # Lee speckle filter implementation
β”‚   β”œβ”€β”€ train.py             # YOLOv8-OBB training pipeline
β”‚   └── inference.py         # Detection and visualization
β”œβ”€β”€ config/
β”‚   └── config.yaml          # Configuration parameters
β”œβ”€β”€ scripts/
β”‚   └── generate_samples.py  # Generate sample outputs
β”œβ”€β”€ assets/                  # README images
β”œβ”€β”€ data/                    # Dataset storage
β”œβ”€β”€ output/                  # Detection results
└── requirements.txt

Quick Start

1. Installation

# Clone the repository
git clone https://github.com/yourusername/Trident.git
cd Trident

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

2. Kaggle Setup

# Configure API credentials
# 1. Go to kaggle.com β†’ Settings β†’ Create New API Token
# 2. Create credentials file:
mkdir -p ~/.kaggle
echo '{"username":"YOUR_USERNAME","key":"YOUR_API_KEY"}' > ~/.kaggle/kaggle.json
chmod 600 ~/.kaggle/kaggle.json

3. Download & Prepare Dataset

# Download SSDD from Kaggle and prepare YOLO OBB format
python src/data_manager.py --download --prepare --data-root ./data

4. Train the Model

# Train with default settings (YOLOv8n-OBB)
python src/train.py --data ./data/ssdd_yolo_obb/data.yaml

# Train with custom settings
python src/train.py \
    --data ./data/ssdd_yolo_obb/data.yaml \
    --model yolov8s-obb \
    --epochs 150 \
    --batch 32 \
    --imgsz 640

5. Run Inference

# Demo mode (random validation images)
python src/inference.py \
    --model ./trident_sar/ship_detection/weights/best.pt \
    --data ./data/ssdd_yolo_obb/data.yaml \
    --output ./output

# Single image
python src/inference.py \
    --model ./trident_sar/ship_detection/weights/best.pt \
    --source /path/to/sar_image.jpg \
    --output ./output

Configuration

Edit config/config.yaml to customize:

preprocessing:
  lee_filter:
    window_size: 7        # Larger = more smoothing

model:
  variant: "yolov8n-obb"  # n/s/m/l/x variants
  image_size: 640

training:
  epochs: 100
  batch_size: 16
  learning_rate: 0.001

Model Variants

Model Size Speed Accuracy
yolov8n-obb 3.2M Fastest Good
yolov8s-obb 11.2M Fast Better
yolov8m-obb 25.9M Medium High
yolov8l-obb 43.7M Slow Higher
yolov8x-obb 68.2M Slowest Highest

API Usage

from src.preprocessing import SARPreprocessor, apply_lee_filter
from src.inference import SARShipDetector

# Preprocess a SAR image
preprocessor = SARPreprocessor(lee_window_size=7)
filtered = preprocessor.process(sar_image)

# Detect ships
detector = SARShipDetector(
    model_path="trident_sar/ship_detection/weights/best.pt",
    confidence_threshold=0.25
)
result = detector.detect("path/to/sar_image.jpg")

print(f"Ships detected: {result['count']}")
for det in result['detections']:
    print(f"  Confidence: {det['confidence']:.2f}")
    print(f"  Angle: {det['angle']:.1f}Β°")

Output Format

Detection results include:

  • corners: 4 corner points of the rotated box
  • center: Center coordinates
  • width, height: Box dimensions
  • angle: Rotation angle in degrees
  • confidence: Detection confidence

Dataset: SSDD

The SAR Ship Detection Dataset (SSDD) used in this project:

Technical Details

Lee Filter Algorithm

The Lee filter assumes multiplicative noise: I = R Γ— N

RΜ‚ = ΞΌ + W Γ— (I - ΞΌ)
W = σ² / (σ² + Οƒ_noiseΒ²)

Where:

  • ΞΌ = local mean
  • σ² = local variance
  • W = adaptive weight (preserves edges)

OBB Output Format

YOLO OBB format: class x1 y1 x2 y2 x3 y3 x4 y4

Four normalized corner coordinates defining the rotated rectangle.

License

MIT License - see LICENSE for details.

Acknowledgments

About

πŸ“‘ Production-grade maritime surveillance system for detecting ships in Synthetic Aperture Radar (SAR) imagery using YOLOv8-OBB (Oriented Bounding Boxes) and Lee speckle filtering. Handles the unique challenges of radar imagery: multiplicative noise and arbitrarily-oriented vessels.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages