Installation¶
Requirements¶
- Python >= 3.10
- uv (recommended for Python versions, virtualenv, and installs)
- PyTorch >= 2.4.0 and TorchVision >= 0.19.0 (see below)
- Pillow >= 9.0
Install from repository (Linux, CUDA 12.1)¶
From the project directory:
cd oriented-det
# Install uv if needed: https://docs.astral.sh/uv/getting-started/installation/
uv venv --python 3.12
source .venv/bin/activate
# PyTorch with CUDA 12.1 (2.4.0 or newer)
uv pip install "torch>=2.4.0" "torchvision>=0.19.0" --index-url https://download.pytorch.org/whl/cu121
# Project dependencies and editable install (includes huggingface_hub for Hub weights)
uv pip install -r requirements.txt
uv pip install -e .
PyTorch and TorchVision (other setups)¶
Follow the official PyTorch installation guide for your OS and CUDA/CPU setup.
For CPU-only:
macOS Apple Silicon (M1/M2/M3)¶
On Mac with Apple Silicon, install the default PyTorch build (no CUDA). PyTorch will use the MPS (Metal Performance Shaders) backend for GPU acceleration:
Then install oriented-det (see below). The library auto-detects MPS and uses the Apple GPU when available. If you hit mixed-precision (AMP) errors on older PyTorch, train with --no-amp. For best MPS and AMP support, use PyTorch 2.5 or newer.
Hands-on: odet image-demo on Apple Silicon (no CUDA toolchain) and Rotated FCOS vs Oriented R-CNN on macOS (MPS latency and score thresholds).
Install OrientedDet (after PyTorch)¶
If you already cloned the repo and installed PyTorch (e.g. via the steps above or for macOS/CPU):
From PyPI:
For development and testing:
This adds pytest, pytest-cov, black, and ruff.
For ONNX export (checkpoint → ONNX, plus ONNX Runtime infer):
See ONNX export.
Photometric Albumentations is optional. No Hub recipe sets enable_albumentation. The extra is the last MIT release (albumentations<=2.0.8); AlbumentationsX is AGPL-3.0:
Without the extra, training still runs. Turning enable_albumentation on raises an import error until the extra is installed.
Verify Installation¶
Or in Python:
import oriented_det
from oriented_det.geometry import RBox, Polygon
from oriented_det.ops import iou, nms
rbox = RBox(100, 200, 50, 30, 0.5)
print(f"RBox area: {rbox.area}")
box1 = RBox(0, 0, 10, 10, 0)
box2 = RBox(5, 5, 10, 10, 0)
overlap = iou.rbox_iou(box1, box2)
print(f"IoU: {overlap}")
Path placeholders in docs and configs¶
Examples throughout this repo use placeholder paths such as /path/to/data and /path/to/oriented-det. You can point commands and JSON configs at your real locations (e.g. dataset.data_root in a training config), or keep those placeholders and map them with symbolic links:
# Create the parent directory (may need sudo for paths under /path/to)
sudo mkdir -p /path/to
# Point the placeholder at your DOTA dataset
ln -s /home/username/dota /path/to/data
# Point the placeholder at your clone of this repo
ln -s /home/username/oriented-det /path/to/oriented-det
After that, copy-pasted commands and unmodified configs that reference /path/to/data or /path/to/oriented-det resolve to your machine. Use relative symlink targets when you want the link to stay valid if the parent directory moves.
Troubleshooting¶
Import Errors¶
If you encounter import errors, make sure:
1. PyTorch is installed: python -c "import torch; print(torch.__version__)"
2. TorchVision is installed: python -c "import torchvision; print(torchvision.__version__)"
3. The package is installed: uv pip list | grep oriented-det (or pip list if you used PyPI only)
GPU Support¶
GPU acceleration is used when available: CUDA (Linux/Windows) or MPS (macOS Apple Silicon). To check:
import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"MPS (Apple Silicon) available: {getattr(torch.backends, 'mps', None) and torch.backends.mps.is_available()}")
Or use the helper:
from oriented_det.utils import get_device
print(get_device()) # e.g. device(type='mps') or device(type='cuda') or device(type='cpu')
Cloud GPUs¶
Published Hub recipes train on 1024×1024 tiles and need about 16–24 GB VRAM per GPU. In-repo DOTA baselines used an RTX 3090 Ti (24 GB); YOLO-OBB and RTMDet finetunes also run well on an L4 (24 GB).
| Workload | Typical recipe knobs | VRAM target |
|---|---|---|
| RTMDet-S (DOTA 3× / MS) | batch 8, AMP off | 24 GB |
| YOLO-OBB-S | batch 4, AMP on | 16–24 GB |
| Oriented / Faster R-CNN | batch 2–4, AMP on; tune roi_chunk_size |
16–24 GB |
| Small finetunes (ships, SAR, Playground) | same as above, fewer steps | 1× 24 GB is enough |
Default: one NVIDIA L4 (24 GB). Use multi-GPU (odet train-multi-gpu / make train-multi-gpu) only when you want shorter wall-clock on large DOTA / MS tile sets. Put tiles and runs/ on local NVMe / SSD, not a remote NFS mount; size the disk for the export + tiles + checkpoints (often 200 GB+ for DOTA-scale data).
Scaleway, Google Cloud, Amazon AWS¶
| Role | Scaleway | Google Cloud | Amazon AWS |
|---|---|---|---|
| Recommended default | L4-1-24G (1× L4 24 GB) |
g2-standard-8 (1× L4 24 GB) |
g6.2xlarge (1× L4 24 GB) |
| More CPU for dataloaders | L4-1-24G is fixed at 8 vCPU; prefer L40S-1-48G if I/O-bound |
g2-standard-12 / g2-standard-16 (still 1× L4) |
g6.4xlarge (still 1× L4) |
| More VRAM / faster | L40S-1-48G |
a2-highgpu-1g (1× A100 40 GB) |
g6e.2xlarge (1× L40S) or g5.2xlarge (1× A10G 24 GB) |
| Usually overkill | H100-1-80G, multi-GPU nodes |
A3 / H100, multi-GPU A2 | p4d / p5 |
Avoid as the default for RTMDet batch 8 with AMP off: T4 / V100 16 GB — drop data_loader.batch_size or enable training.use_amp first. Spot / preemptible / interrupted instances are fine when you can resume from runs/<model_type>/<timestamp>/.
Scaleway L4 is available in Paris and Warsaw; L40S / H100 in selected AZs there. Prefer a cloud region close to your dataset storage.