π’ Ship Detection in SAR Imagery β Faster R-CNN (HRSID)
A Faster R-CNN model trained on the HRSID dataset for robust ship detection in high-resolution Synthetic Aperture Radar (SAR) imagery. Upload a SAR image to detect ships in real time.
π§ Model Architecture
| Component | Detail |
|---|---|
| Framework | Detectron2 |
| Detector | Faster R-CNN |
| Backbone | ResNet-50 + FPN |
| Classes | 1 (Ship) |
| Input Size | 1400 Γ 1400 |
| Inference | CPU-compatible (HF Spaces free) |
π Training Configuration
| Parameter | Value |
|---|---|
| Dataset | HRSID (train / val / test) |
| Train Images | 2,914 |
| Val Images | 728 |
| Test Images | 5,604 |
| Total Instances | 16,951 ships |
| Max Iterations | 5,000 |
| Batch Size | 2 |
| Base Learning Rate | 0.00025 |
| Optimizer | SGD |
| Eval Period | Every 500 iterations |
| Checkpoint Period | Every 500 iterations |
| Score Threshold | 0.5 |
| GPU | Tesla T4 (15.6 GB VRAM) |
Augmentations: Resize to 1400 Γ 1400, random horizontal flip.
π Evaluation Results
Evaluated on the HRSID test split (5,604 images) using COCO-style metrics.
| Metric | Value |
|---|---|
| AP (IoU=0.50:0.95) | 47.39 |
| AP50 (IoU=0.50) | 71.88 |
| AP75 (IoU=0.75) | 56.53 |
| APs (small objects) | 48.54 |
| APm (medium objects) | 48.55 |
| APl (large objects) | 23.17 |
| AR @ maxDets=1 | 24.30 |
| AR @ maxDets=10 | 49.20 |
| AR @ maxDets=100 | 52.40 |
| AR small @ maxDets=100 | 50.60 |
| AR medium @ maxDets=100 | 66.70 |
| AR large @ maxDets=100 | 44.60 |
π° Dataset
HRSID (High-Resolution SAR Images Dataset) is a benchmark for ship detection and instance segmentation in SAR imagery.
- 5,604 SAR image crops
- 16,951 annotated ship instances (bounding boxes + segmentation masks)
- Multi-scale vessel distribution across coastal and open-sea scenarios
- Derived from Sentinel-1, TerraSAR-X, and TanDEM-X satellite imagery
βοΈ Inference
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
import cv2
cfg = get_cfg()
cfg.merge_from_file("config.yaml")
cfg.MODEL.WEIGHTS = "model_final.pth"
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
cfg.MODEL.DEVICE = "cpu" # or "cuda"
predictor = DefaultPredictor(cfg)
image = cv2.imread("test_sar.jpg")
outputs = predictor(image)
instances = outputs["instances"]
print(f"Detected {len(instances)} ships")
print(f"Boxes: {instances.pred_boxes}")
print(f"Scores: {instances.scores}")
π¦ Repository Files
| File | Description |
|---|---|
model_final.pth |
Trained Faster R-CNN weights |
config.yaml |
Detectron2 model configuration |
labels.json |
Class label mapping {0: "ship"} |
app.py |
Gradio inference app |
requirements.txt |
Python dependencies |
π Run Locally
git clone https://huggingface.co/PUSHPENDAR/hrsid-ship-detection
cd hrsid-ship-detection
pip install -r requirements.txt
python app.py
π Citation
@article{wei2020hrsid,
title={HRSID: A High-Resolution SAR Images Dataset for Ship Detection and Instance Segmentation},
author={Wei, Shunjun and Zeng, Xiangfeng and Qu, Qizhe and Wang, Mou and Su, Hao and Shi, Jun},
journal={IEEE Access},
volume={8},
pages={96962--96980},
year={2020},
publisher={IEEE}
}
π License
Apache 2.0 β see LICENSE for details.
- Downloads last month
- 10