Skip to content

Commit 94b6273

Browse files
committed
init (cleanup): final commit
0 parents  commit 94b6273

21 files changed

Lines changed: 1198 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v7
13+
- uses: actions/setup-python@v7
14+
with:
15+
python-version: "3.11"
16+
cache: pip
17+
- name: Install
18+
run: |
19+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
20+
pip install -e ".[dev]"
21+
- name: Lint
22+
run: |
23+
ruff check .
24+
ruff format --check .
25+
- name: Test
26+
run: pytest -q

‎.gitignore‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.egg-info/
4+
.venv/
5+
.pytest_cache/
6+
.ruff_cache/
7+
build/
8+
dist/
9+
10+
# datasets, training outputs and exported models
11+
/data/
12+
/runs/
13+
*.pt
14+
*.pth
15+
*.onnx
16+
*.engine
17+
18+
# rendered Slurm scripts and logs
19+
slurm/generated/
20+
slurm/logs/
21+
slurm/cluster.local.toml
22+
23+
# private notes
24+
*.private.md
25+
26+
.DS_Store
27+
.ipynb_checkpoints/
28+
/models/
29+
*.mp4
30+
/assets/raw/
31+
32+
# environments, editors and secrets
33+
.env
34+
.env.*
35+
!.env.example
36+
.mypy_cache/
37+
.coverage
38+
htmlcov/
39+
.idea/
40+
.vscode/
41+
*.log
42+
*.onnx.data
43+
*.ckpt
44+
*.safetensors

‎.pre-commit-config.yaml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.16.10
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v6.0.0
10+
hooks:
11+
- id: end-of-file-fixer
12+
- id: trailing-whitespace
13+
- id: check-yaml
14+
- id: check-added-large-files
15+
args: [--maxkb=2000]

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Kacper Pawlowski
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎Makefile‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.PHONY: install dev lint format test data models jobs
2+
3+
install:
4+
pip install -e ".[train]"
5+
6+
dev:
7+
pip install -e ".[dev]"
8+
9+
lint:
10+
ruff check .
11+
ruff format --check .
12+
13+
format:
14+
ruff format .
15+
ruff check --fix .
16+
17+
test:
18+
pytest -q
19+
20+
data: ## VisDrone2019-DET + COCO JSON with ignore regions
21+
bash scripts/download_data.sh
22+
23+
models: ## COCO-pretrained YOLO26 weights
24+
bash scripts/download_models.sh
25+
26+
jobs:
27+
python3 slurm/generate.py --list

‎README.md‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Drone object detection
2+
3+
People and vehicles seen from a drone are small: of the 75,102 objects in VisDrone's test-dev
4+
split, 68 % are under 32 x 32 pixels in the original photo, and a 2000 x 1500 image shrunk to the
5+
usual 640 px input keeps a third of each object's width. This project trains YOLO26s three ways
6+
and asks which helps small objects more: more pixels in training, more pixels at inference, or
7+
both.
8+
9+
- **Whole image at 640 px**, the default setting.
10+
- **Whole image at 1280 px**, four times the pixels, four times the compute.
11+
- **640 px tiles** with 20 % overlap (slicing-aided inference, Akyon et al., ICIP 2022), trained on
12+
tiles cut from the training images, predicted tile by tile and merged with class-wise NMS.
13+
14+
![tile-trained YOLO26s on VisDrone test-dev photos](assets/detections.gif)
15+
<sub>Tile-trained YOLO26s on unseen VisDrone test-dev photos. Images: VisDrone (AISKYEYE,
16+
Tianjin University), for academic use.</sub>
17+
18+
Scores follow the VisDrone toolkit, not plain COCO: ignored regions (crowds, far clutter) and the
19+
"others" class are crowd boxes that neither reward nor punish a detection, and AP counts up to
20+
500 detections per image.
21+
22+
## Results
23+
24+
VisDrone2019-DET test-dev (1610 images), YOLO26s from COCO weights, AP in % over IoU 0.50:0.95;
25+
small objects are under 32 x 32 px in the original image. Time per image on one H100 GPU:
26+
27+
| Training | Inference | AP | AP50 | AP small | AP medium | AP large | ms / image |
28+
|---|---|---|---|---|---|---|---|
29+
| whole image, 640 | whole image, 640 | 17.4 | 30.4 | 8.8 | 26.2 | 38.3 | 7 |
30+
| whole image, 1280 | whole image, 1280 | 25.6 | 43.3 | 15.7 | 36.4 | 47.2 | 8 |
31+
| whole image, 640 | tiles | 18.5 | 33.7 | 12.4 | 25.8 | 22.6 | 13 |
32+
| tiles | tiles | 26.2 | **45.3** | **16.3** | 37.5 | 46.5 | 15 (A100) |
33+
| **tiles** | **tiles + whole image** | **26.5** | **45.3** | 16.2 | **37.7** | **49.6** | 14 |
34+
35+
- **More pixels are what small objects need.** At 1280 px the same network reaches 25.6 AP
36+
instead of 17.4, and nearly doubles the AP on small objects (15.7 against 8.8), for one
37+
millisecond more per image on an H100.
38+
- **Tiles need to be trained on.** The 640 model predicted on tiles finds more small objects
39+
(12.4) but loses large ones that the tile borders cut. Trained on tiles, the same network
40+
reaches 26.2 AP, and one extra pass over the whole image recovers the large objects: **26.5 AP,
41+
45.3 AP50 and 49.6 AP on large objects**, the best of all five, at 14 ms per image.
42+
- **Which one to deploy.** Tiles keep a 640 px input, so one model works on any camera
43+
resolution, from a 2.7K drone camera to a 4K one, by adding tiles. The 1280 model is the
44+
simpler choice when the camera resolution is fixed and the onboard computer is tight.
45+
46+
The third row uses the same weights as the first row, only predicted on tiles, which separates
47+
the effect of training from the effect of inference.
48+
49+
## Quickstart
50+
51+
```bash
52+
pip install -e ".[train]"
53+
bash scripts/download_models.sh # COCO-pretrained YOLO26 weights
54+
bash scripts/download_data.sh # VisDrone train / val / test-dev, 1.8 GB
55+
aerial-slice --data data/visdrone # 640 px tiles of train and val + tiles640.yaml
56+
aerial-train --data data/visdrone/visdrone.yaml --imgsz 640 --batch 32 --name visdrone_640
57+
aerial-train --data data/visdrone/tiles640.yaml --imgsz 640 --batch 32 --epochs 40 --name visdrone_tiles640
58+
aerial-eval --model runs/visdrone_640/weights/best.pt --data data/visdrone --split test
59+
aerial-eval --model runs/visdrone_tiles640/weights/best.pt --data data/visdrone --split test --tiled
60+
```
61+
62+
## Training on a GPU cluster (Slurm)
63+
64+
```bash
65+
bash scripts/setup_cluster.sh && bash scripts/download_models.sh && bash scripts/download_data.sh
66+
python3 slurm/generate.py slice --submit # CPU
67+
python3 slurm/generate.py train --submit # array: 640, 1280, tiles
68+
python3 slurm/generate.py evaluate --submit # array: the five rows of the table
69+
```
70+
71+
Account and paths come from `slurm/cluster.toml`; put your account in the git-ignored
72+
`slurm/cluster.local.toml`. Downloads run on a login node, jobs run offline.
73+
74+
## Project layout
75+
76+
```
77+
src/aerial/
78+
visdrone.py download, YOLO labels for training, COCO JSON with ignore regions for scoring
79+
tiling.py tile grid, training tiles, tiled prediction + merging
80+
train.py Ultralytics training with resume
81+
evaluate.py COCO AP by object size with 500 detections per image, time per image
82+
```
83+
84+
## Data and licence
85+
86+
The code is MIT-licensed. VisDrone (Zhu et al., TPAMI 2021, AISKYEYE team, Tianjin University) is
87+
for academic use; it is downloaded by the script and never committed.
88+
89+
## References
90+
91+
- P. Zhu et al., *Detection and Tracking Meet Drones Challenge*, TPAMI 2021 (VisDrone).
92+
- F. C. Akyon, S. O. Altinuc, A. Temizel, *Slicing Aided Hyper Inference and Fine-tuning for
93+
Small Object Detection*, ICIP 2022.
94+
- Ultralytics YOLO26 (2026).

‎assets/detections.gif‎

1.24 MB
Loading

‎assets/detections.jpg‎

245 KB
Loading

‎pyproject.toml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools>=69"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "drone-object-detection"
7+
version = "0.1.0"
8+
description = "Small objects from a drone: YOLO26 on VisDrone at 640 px, at 1280 px and on overlapping tiles, scored with the official ignore regions and AP by object size."
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [{ name = "Kacper Pawlowski" }]
12+
requires-python = ">=3.11"
13+
dependencies = [
14+
"numpy>=1.26",
15+
"opencv-python-headless>=4.9",
16+
"pillow>=10",
17+
"requests>=2.31",
18+
"torch>=2.3",
19+
"torchvision>=0.18",
20+
"pycocotools>=2.0.8",
21+
]
22+
23+
[project.optional-dependencies]
24+
train = ["ultralytics>=8.4"]
25+
dev = ["pytest>=8", "ruff>=0.6"]
26+
27+
[project.scripts]
28+
aerial-data = "aerial.visdrone:main"
29+
aerial-slice = "aerial.tiling:main"
30+
aerial-train = "aerial.train:main"
31+
aerial-eval = "aerial.evaluate:main"
32+
33+
[tool.setuptools.packages.find]
34+
where = ["src"]
35+
36+
[tool.ruff]
37+
line-length = 110
38+
target-version = "py311"
39+
40+
[tool.ruff.lint]
41+
select = ["E", "F", "W", "I", "UP", "B", "SIM", "NPY"]
42+
43+
[tool.pytest.ini_options]
44+
testpaths = ["tests"]
45+
addopts = "-ra"

‎scripts/download_data.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# VisDrone2019-DET train / val / test-dev (1.8 GB, from the Ultralytics asset mirror) -> YOLO
3+
# labels and COCO JSON with ignore regions. Run on a login node (needs internet).
4+
# bash scripts/download_data.sh # into $DATA/visdrone (cluster) or ./data/visdrone
5+
set -euo pipefail
6+
cd "$(dirname "$0")/.."
7+
python -m aerial.visdrone --out "${DATA:-data}/visdrone"

0 commit comments

Comments
 (0)