Skip to content

zxq309/SGGB

Repository files navigation

SGGB: Scale-Gated Gradient Bridging for Tiny Person Detection in Aerial Imagery

Paper Python PyTorch License

Official implementation of "Scale-Gated Gradient Bridging for Tiny Person Detection in Aerial Imagery" (submitted to IEEE Transactions on Geoscience and Remote Sensing).

Xiangqing Zhang, Yan Feng, Shun Zhang, Nan Wang, Guohua Lu, and Shaohui Mei


πŸ”₯ News

  • [2026-07] Code release: SGGB / CDG / DAS training-time add-ons for Ultralytics YOLO26, with full reproduction scripts and 40+ training-run protocols.

πŸ“– Abstract

End-to-end detectors such as YOLO26 abandon NMS by training a dense one-to-many (o2m) branch jointly with a sparse one-to-one (o2o) branch, yet the o2o head is architecturally forbidden from shaping the shared features it reads at inference. SGGB (Scale-Gated Gradient Bridging) opens a gradient-only path from the o2o branch back into the shared backbone/neck features β€” the forward computation graph is bit-identical to the baseline, and a single coefficient Ξ» gates the bridge, so Ξ» = 0 exactly reproduces the stock model. A cosine-decay schedule stabilizes the bridge across input resolutions. Two companion mechanisms (CDG: cross-head gradient deconfliction; DAS: disagreement-adaptive supervision) are included as honest negative-result ablations. On three aerial person-detection benchmarks (TinyPerson, AFO, HERIDAL), SGGB yields consistent gains that are largest on the tiniest objects (Tiny1 bin, h < 10 px: +0.020 AP50), and a gradient-flow probe verifies the intended 1.45–2.03Γ— gradient amplification on shared features.

✨ Highlights

  • Zero inference cost & bit-identical forward pass β€” SGGB touches only the backward graph; deployment models are unchanged.
  • One-knob ablatable design β€” SGGB_LAMBDA=0 exactly reproduces baseline YOLO26 (verified by unit + integration tests).
  • Gains concentrate where they matter β€” improvement is inversely proportional to object size (Tiny1 +0.020 > Tiny2 +0.016 > Small +0.008 > Medium +0.007 AP50).
  • Honest negative results β€” CDG and DAS ablations included; everything is controlled by environment variables, no code edits needed.
  • Full reproducibility β€” 40+ runs, ~260 GPU hours, 3 datasets Γ— 3 seeds, Docker environment and suite scripts provided.

πŸ—οΈ Method Overview

SGGB forks the shared feature pyramid at training time: the o2m branch consumes the original tensors, while the o2o branch consumes a Ξ»-scaled view. Gradients from the o2o loss therefore flow back into the shared features through the bridge with strength Ξ», letting the inference-time head participate in representation learning. CDG optionally deconflicts the o2m/o2o gradient directions at the shared-feature level (Ξ²), and DAS reweights supervision by head disagreement (W).

πŸ“Š Results

Cross-dataset generalization (YOLO26-S, imgsz = 1280, 3-seed mean Β± Οƒ)

Dataset Train/Val Baseline mAP50 + SGGB-cos mAP50 Ξ”
TinyPerson 717/100 0.492 Β± 0.004 0.495 Β± 0.009 +0.003
AFO 1,896/211 0.957 Β± 0.001 0.960 Β± 0.002 +0.003
HERIDAL 978/101 0.715 Β± 0.010 0.720 Β± 0.006 +0.005

TinyPerson height-binned AP50 (official protocol, 1280)

Height bin (px) n_GT Baseline SGGB-cos Ξ”
Tiny1 (h < 10) 535 0.441 0.461 +0.020
Tiny2 (10 ≀ h < 20) 709 0.461 0.477 +0.016
Small (20 ≀ h < 32) 369 0.462 0.470 +0.008
Medium (h β‰₯ 32) 526 0.486 0.492 +0.007
All 2,139 0.454 0.468 +0.013

Comparison with detectors under identical protocol (TinyPerson, 1280, seed 0)

Model Params mAP50 mAP50-95
YOLOv8-S 11.1 M 0.466 0.160
YOLOv10-S 7.2 M 0.461 0.157
YOLO26-S (baseline) 9.5 M 0.492 0.174
YOLO26-S + SGGB-cos 9.5 M 0.500 0.179

Mechanism verification (gradient-flow probe)

Amplification ratio β€–βˆ‡_shared(Ξ» = 0.5)β€– / β€–βˆ‡_shared(Ξ» = 0)β€– measured on shared backbone/neck features: 1.45–2.03Γ— across TinyPerson / AFO / HERIDAL.

Qualitative comparison (baseline vs. +SGGB)

πŸ“ Repository Structure

β”œβ”€β”€ ultralytics/              # YOLO26 source with SGGB/CDG/DAS add-ons
β”‚   β”œβ”€β”€ nn/modules/head.py    #   ← SGGB bridge (Ξ» gate, cosine/linear schedule)
β”‚   β”œβ”€β”€ utils/cdg.py          #   ← CDG deconfliction (Ξ²) + DAS weight (W)
β”‚   └── engine/trainer.py     #   ← epoch injection for Ξ» schedules
β”œβ”€β”€ tests/                    # unit + gradient-flow integration tests
β”‚   β”œβ”€β”€ test_cdg_math.py
β”‚   └── test_cdg_gradflow.py
β”œβ”€β”€ configs/                  # dataset YAMLs (TinyPerson / AFO / HERIDAL)
β”œβ”€β”€ docker/                   # reproducible training environment
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ run_dataset_suite.sh      # one-command 3-seed Γ— {baseline, SGGB} suite
β”œβ”€β”€ gradflow_probe.py         # gradient amplification measurement
└── RESEARCH_CHANGES.md       # detailed changelog vs. stock Ultralytics

βš™οΈ Installation

# Docker (recommended β€” matches the paper environment)
docker compose up -d
pip install -e .

# Or bare-metal
conda create -n sggb python=3.11 -y && conda activate sggb
pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu124
pip install -e .

πŸš€ Quick Start

All mechanisms are controlled purely by environment variables β€” no code edits:

# Baseline (stock YOLO26 β€” all switches off)
export SGGB_LAMBDA=0.0 CDG_BETA=0.0 DAS_W=0.0

# SGGB with fixed Ξ»
export SGGB_LAMBDA=0.5

# SGGB with cosine decay (recommended; used in the paper)
export SGGB_LAMBDA=0.5 SGGB_SCHEDULE=cosine

# Optional companions (active only when Ξ» > 0)
export CDG_BETA=0.25     # cross-head gradient deconfliction
export DAS_W=0.1         # disagreement-adaptive supervision

# Train exactly like stock Ultralytics
yolo detect train model=yolo26s.pt data=configs/tinyperson.yaml imgsz=1280 epochs=100 batch=4

πŸ” Reproducing the Paper

# 3-seed Γ— {baseline, SGGB-cos} suite for one dataset (~6 runs)
bash run_dataset_suite.sh tinyperson configs/tinyperson.yaml yolo26s.pt 0
bash run_dataset_suite.sh afo        configs/afo.yaml        yolo26s.pt 0
bash run_dataset_suite.sh heridal    configs/heridal.yaml    yolo26s.pt 0

# Gradient-flow amplification probe
python gradflow_probe.py --weights runs/detect/<run>/weights/best.pt

# Sanity checks (all-switches-off == baseline)
pytest tests/test_cdg_math.py tests/test_cdg_gradflow.py

Protocol: YOLO26-S, COCO-pretrained, AdamW (lr = 0.002, cosine LR), 100 epochs, AMP off, batch 4 (2 at 1920), RTX 4090 24 GB.

πŸ“Œ Citation

@article{zhang2026sggb,
  title   = {Scale-Gated Gradient Bridging for Tiny Person Detection in Aerial Imagery},
  author  = {Zhang, Xiangqing and Feng, Yan and Zhang, Shun and Wang, Nan and Lu, Guohua and Mei, Shaohui},
  journal = {IEEE Transactions on Geoscience and Remote Sensing},
  year    = {2026},
  note    = {submitted}
}

πŸ™ Acknowledgement & License

This repository is built on Ultralytics YOLO26 (v8.4.80, editable install). It inherits the AGPL-3.0 license β€” see LICENSE. Datasets: TinyPerson, AFO, HERIDAL β€” please cite the original dataset papers when using them.

About

Scale-Gated Gradient Bridging for Tiny Person Detection in Aerial Imagery (IEEE TGRS)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages