Selected work / Case study
Density-Aware Vehicle Counting
A research prototype extending pretrained YOLO26s with attention, small-object features, and density-aware training loss, then evaluating vehicle detections and line-crossing counts.

The problem
Study vehicle detection and counting in crowded, occluded traffic scenes, while examining how attention, a finer feature scale, and density-weighted training affect the research pipeline.
Engineering focus
Implement HAM attention, a stride-4 P2 detection scale, and DALW on both training-loss branches; connect one-to-one predictions to tracking and evaluate detection separately from counting.
Implementation overview
Prepare and inspect data
Review authorized labels and scene/density strata; retain provenance and duplicate limitations.
Train model variants
Transfer pretrained YOLO26s weights and combine HAM, P2, and DALW experiments.
Detect and track
Run one-to-one detections and ByteTrack on images or video frames.
Count and evaluate
Compare virtual-line interval counts with manual labels, separately from detection metrics.
Inspect locally
A local FastAPI tester offers image/video review with in-memory jobs and filesystem artifacts.
Implementation
- Build eight HAM/P2/DALW combinations using pretrained YOLO26s parameter transfer, with separate training, prediction-cache, and evaluation scripts.
- Weight foreground training losses from post-augmentation ground-truth center density on the one-to-many and one-to-one branches; DALW adds no density service at inference time.
- Prepare 640-pixel letterboxed RGB inputs and map one-to-one output boxes back to the original image coordinates.
- Connect detections to ByteTrack and a virtual line, recording interval, class, and direction counts; exclude pedestrians from vehicle totals.
- Provide a local HTML/JavaScript tester through FastAPI for images and asynchronous video jobs. Job state is process-local and artifacts are filesystem files, with no application database.
- Compare global and stratified detection results, a 3 × 3 DALW validation grid, manual occlusion labels, and manual versus predicted line counts; retain the experimental defects alongside the plots.
Evidence & source
The package records 3,389 dataset images and three ten-minute counting clips, summarized as 180 interval/class/direction observations. Historical counting MAE is 1.9722, RMSE 4.9469, and MAPE 37.17% after excluding 68 zero-ground-truth cells from MAPE. Mean pipeline speed is 20.47 FPS against 30 FPS source footage. A saved 60-epoch validation grid selects alpha 1.0 and sigma 0.1; its 0.66697 mAP50–95 is a validation result, not a test score. These figures and plots were not reproduced in this portfolio update. Linked files identify a reviewed commit, but the supplied snapshot also includes uncommitted changes and has no complete hosted snapshot or verified demo.
Decisions & limitations
The global DALW patch can persist from V4 to V5 in sequential runs, so V8 versus V5 does not isolate the DALW effect. Empty-prediction AP and empty-object batches have known evaluator/loss defects; their historical impact is unresolved. Confidence filtering removes ByteTrack low-score candidates, and cache reuse does not check split or checkpoint identity. Training uses one seed, with overlapping strata and limited extreme-density samples. Occlusion-proxy agreement is 68%, with no heavy-tier predictions in that check. Counting uses one manual observer and excludes a clip for line geometry. Mixed dataset provenance, watermarks, and cross-split near-duplicates limit conclusions. No causal improvement, field accuracy, or production readiness is claimed; raw data and weights are excluded.