wikillm

Paper · 2017-12-18 · cs.CV

DecideNet: Counting Varying Density Crowds Through Attention Guided Detection and Density Estimation

DecideNet counts people by blending a detection density map (Faster R-CNN head boxes as Gaussian bumps) with a regression density map (5-layer CNN). A 4-layer attention net (QualityNet) weights the two per pixel and is trained with a detection-score quality term. Author-reported: lowest MAE on Mall (1.52) and WorldExpo'10 (9.23 average); MAE 21.53 on ShanghaiTech PartB.

Density map regressionObject detectionAttention mechanismcrowd-countingdensity-mapattentiondetection-regression-fusionobject-detection

arXivPDFMarkdown9 min read

AI-compiled by claude-haiku-5-5 on 2026-11-01, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Counting a crowd from a camera image is hard because crowds are not equally dense everywhere. Some parts of a picture hold a few well-separated people, and other parts hold a dense mass. There are two common ways to count. One finds each person and counts the detections. This works well when people are far apart, but it misses many people when they overlap or are tiny. The other learns a "density" map that adds up to the count without finding anyone. This works well in dense areas, but in sparse areas it tends to over-count.

DecideNet runs both methods at once and learns when to trust which one. Each part of the image gets a score that says how much to rely on the detector and how much on the density estimate. The two maps are blended with those scores, and the total of the blended map is the crowd count. The scores are learned during training, and a detection-based signal helps teach them where the detector can be trusted.

TL;DR

DecideNet is an end-to-end crowd counter that outputs one density map from two sources: a detector's head boxes turned into Gaussian bumps, and a small regression network. A pixel-wise attention network chooses the blend. The authors report the best MAE among the compared methods on Mall and WorldExpo'10, and a competitive but not best MAE on ShanghaiTech PartB. Code: none found (see Paper vs code).

Problem

Crowd counting must cope with density that changes across space and time within one scene §1 fig. 1. The authors report that detection scores drop as the ground-truth count per patch rises, so detection under-counts in crowded areas §1 fig. 1(c). They report that regression maps over-count in sparse areas and in background regions, because they do not know where people are §1 fig. 1(d). Neither method alone is judged adequate across the whole density range §1.

Method

The model has three CNN blocks, parameterised by Ω = (Ω_det, Ω_reg, Ω_qua) and trained jointly §3:

  1. RegNet produces a regression density map D^reg from the image patch, without locating heads §3.2 fig. 3. It is a five-layer fully convolutional network with a ReLU after the last layer §3.2 eq. 2.
  2. DetNet is a Faster R-CNN head detector on a ResNet-101 backbone §3.3. A fixed Gaussian is placed at the centre of each detected box and the results are summed into D^det, so D^det is "location aware" §3.3 eq. 3 fig. 4.
  3. QualityNet takes D^det, D^reg (both upsampled to image size) and the image I_i stacked into five channels. Four convolutional layers and a pixel-wise sigmoid output an attention map K with values in (0, 1), where a larger value means "trust detection here" §3.4 fig. 5.
  4. The final density is the attention-weighted sum of the two maps §3.4 eq. 4:

D^{final}(p) = K(p) \odot D^{det}(p) + (\mathbf{J} - K(p)) \odot D^{reg}(p) eq. 4

The count of a region is the sum of D^final over its pixels §3.1.

Ground truth is a density map made by placing a Gaussian at each annotated head point and summing; the sum over pixels equals the head count §3.1 eq. 1.

The training loss is the sum of three terms, one per block §4 eq. 5:

L_{decide} = L_{reg} + L_{det} + L_{qua} eq. 5

  • L_reg: pixel-wise squared error between D^reg and the ground-truth density, averaged over training images §4 eq. 6.
  • L_det: the Faster R-CNN classification and box-localisation losses, with the ground-truth boxes made from the average box size §4 eq. 7.
  • L_qua: the pixel-wise squared error between D^final and the ground truth, plus λ times the squared difference between K and the detection-score map S^det §4 eq. 8. The authors call this the "quality-aware" loss §4.

Per iteration, the three loss gradients are computed in turn, and each one updates only its own block's parameters §4.

Pseudocode
# DecideNet training step  [§3] [§4]
# Input:  patch (3, h, w); head points and boxes for the patch
# Output: L_decide = L_reg + L_det + L_qua  (scalar)

def decidenet_loss(patch, head_points, boxes_gt, num_images):
    # RegNet: 5-layer fully convolutional regression map  [§3.2] [fig. 3]
    density_reg = regnet(patch)                       # (h', w'), ReLU output
    # DetNet: Faster R-CNN head boxes, Gaussian at each box centre  [§3.3]
    boxes, scores = faster_rcnn(patch)
    density_det = gaussian_at_centres(boxes)          # sigma not stated
    # Per-pixel detection score map S_det, 0.1 outside all boxes  [§5.1]
    score_map = fill_scores(boxes, scores, default=0.1)
    # Bring both maps to image size for QualityNet  [§3.4]
    density_reg_up = upsample(density_reg, patch)     # method not stated
    density_det_up = upsample(density_det, patch)
    # QualityNet: attention K in (0, 1) per pixel  [§3.4] [fig. 5]
    stacked = concat(density_det_up, density_reg_up, patch)
    attention = qualitynet(stacked)                   # (h, w), sigmoid
    # Attention-weighted fusion of the two maps  [§3.4] [eq. 4]
    density_final = (attention * density_det
                     + (1 - attention) * density_reg)
    # Regression loss: squared error summed over pixels, over N  [§4] [eq. 6]
    loss_reg = sum_pixels((density_reg - gt_density) ** 2) / num_images
    # Detection loss: Faster R-CNN cls + loc, box size = average  [§4] [eq. 7]
    loss_det = faster_rcnn_loss(boxes, boxes_gt) / num_images
    # Quality loss: final error + lam * (K - S_det)^2  [§4] [eq. 8]
    loss_qua = (sum_pixels((density_final - gt_density) ** 2)
                + lam * sum_pixels((attention - score_map) ** 2)) / num_images
    # Count of the region is the sum of density_final  [§3.1]
    return loss_reg + loss_det + loss_qua

Hyperparameters

NameValueWhereNotes
Training iterations40k§5.1same for all datasets
Initial learning rate0.005§5.1halved every 10k steps
OptimizerSGD§4 §5.1momentum, weight decay, batch size: not stated
Model selectionbest on validation§5.1validation metric not stated
Patch cropping4 × 3 grid of patches§5.1grid orientation not stated; SHB patches 256 × 256 §5.3
Random flipshorizontal and vertical, p = 0.5§5.1
Uniform pixel noisein [−5, 5], p = 0.5§5.1pixel intensity scale not stated
GT Gaussian σ4.0§5.1window size 15 §5.1
Detection score fill0.1 outside boxes§5.1
λ (quality loss weight)not stated§4 eq. 8
Detector Gaussian σnot stated§3.3 eq. 3
RegNet conv120 filters, 7 × 7, then 2 × 2 max-pool§3.2 fig. 3
RegNet conv240 filters, 5 × 5, then 2 × 2 max-pool§3.2 fig. 3
RegNet conv320 filters, 5 × 5§3.2
RegNet conv410 filters, 5 × 5§3.2
RegNet conv51 filter, 1 × 1, ReLU§3.2output D^reg
RegNet activations, padding, stridenot stated (ReLU only after conv5)§3.2
QualityNet layersfour conv layers (7 × 7/20, 5 × 5/40, 5 × 5/20, 1 × 1), then sigmoid§3.4 fig. 5padding, stride, activations and the output channel count of conv4 not stated
DetNet backboneFaster R-CNN, ResNet-101§3.3pretraining and detector training schedule not stated
Box labelsboxes drawn by hand on part of the training points; average width and height used for all heads§4number of boxed images not stated
Mall splitfirst 800 frames train, rest 1200 test; 100 random train frames for validation§5.2
SHB split400 train, remaining 316 test; 50 train images for validation§5.3716 images, 768 × 1024
WorldExpo'10 split3380 train frames; rest (600, derived) test§5.4patch 144 × 144; count only inside ROI

Results

Author-reported. All numbers are MAE and MSE on each dataset's test split §5.1. The paper does not write a formula for MSE beyond "mean squared error" §5.1.

Mall dataset (320 × 240 frames) §5.2 tab. 1:

MethodMAEMSEType
SquareChn Detector20.55439.1detection
R-FCN6.025.46detection
Faster R-CNN5.916.60detection
Count Forest4.402.40regression
Exemplary Density1.822.74regression
Boosting CNN2.01N/Aregression
MoCNN2.7513.40regression
Weighted VLAD2.419.12regression
DecideNet1.521.90both

ShanghaiTech PartB §5.3 tab. 2:

MethodMAEMSE
R-FCN52.3570.12
Faster R-CNN44.5153.22
Cross-scene32.0049.80
M-CNN26.4041.30
FCN23.7633.12
Switching-CNN21.6033.40
CP-CNN20.130.1
DecideNet21.5331.98
DecideNet+R320.7529.42

DecideNet+R3 adds an extra R3 stream taken from Switching-CNN §5.3.

WorldExpo'10, MAE per scene, counting only inside the ROI §5.4 tab. 3:

MethodS1S2S3S4S5Ave
Cross-scene2.0029.509.709.303.1012.90
M-CNN3.4020.6012.9013.008.1011.60
Local&Global7.8015.4015.3025.604.1011.70
CNN-pixel2.9018.6014.1024.606.9013.40
Switching-CNN4.4015.7010.0011.005.909.40
DecideNet2.0013.148.9017.404.759.23

Ablation on Mall and SHB §5.5 tab. 4:

VariantMAE MallMAE SHBMSE MallMSE SHB
RegNet only3.3742.854.2263.63
DetNet only4.5044.905.6073.18
RegNet + DetNet (late fusion, average)3.9338.634.9665.27
RegNet + DetNet + QualityNet1.8324.932.2741.86
RegNet + DetNet + QualityNet, quality-aware loss1.5221.531.9031.98

The paper reports that RegNet alone beats DetNet alone on both datasets, that late fusion helps on SHB but only mediocrely on Mall, and that the attention block roughly halves the MAE of late fusion. Adding the quality-aware loss lowers error further on both §5.5. The per-image count curves are in fig. 6.

Paper vs code

No official code.

The paper names no repository, no project page and no code availability statement [arXiv abstract, §1–§6]. A GitHub repository search for "DecideNet" returned four repositories, none owned by an author: kbonna/decidenet is an fMRI and behavioural study with the same project name, and the other three are personal repositories. Further searches in this session returned HTTP 403, so the search is not exhaustive.

Pitfalls

  • Density resolution. RegNet has two 2 × 2 max-pools §3.2, so its output is smaller than the patch. The paper defines D^reg per pixel of I_i §3.2 but then says QualityNet "upsamples" both maps to image size §3.4. The upsampling method is not stated, and it is not stated whether the final blend in eq. 4 uses the upsampled or native-size maps.
  • Detector Gaussian. The σ of the Gaussian placed on detected centres eq. 3 is not stated. Detection thresholding and non-maximum suppression are also not stated, though both change D^det directly.
  • Gradient path to the detector. D^det depends on the detected box centres, which are discrete outputs. How gradients from L_qua reach Ω_det, and whether the score map S^det is detached, is not stated.
  • Loss scale. L_reg and L_qua sum over pixels and divide by N, the number of training images eq. 6 eq. 8, not by the pixel count. The batch size and whether N is per batch or per dataset are not stated. The value of λ is not stated, so the balance between the two parts of L_qua is unknown.
  • Distance type. The text says "Euclidean distances" §4, but eq. 8 uses a squared norm. Taking the root changes the scale of the term.
  • Alternating updates. "Alternatively calculated" §4 could mean one loss per iteration or all three each iteration. The paper does not say.
  • Per-iteration detector cost. The detection score map is produced by running DetNet on every training patch in every iteration §5.1. The training cost of this is not reported, and inference cost is not reported.
  • Box supervision. Box sizes are taken as the average over a hand-labelled subset of training heads §4. The subset size and whether the average is per dataset are not stated, and the authors say this constant is used for all heads. Accuracy on scenes with very different head sizes is not evaluated in the paper.
  • Inference procedure. Training uses patches §5.1. Whether test images are processed whole or in patches, and how patches are stitched, is not stated.
  • Random noise units. Noise of [−5, 5] per pixel §5.1 needs the pixel intensity scale, which is not stated.
  • Headline claims. The abstract and conclusion claim state-of-the-art on all three datasets §6. The tables show CP-CNN with a lower SHB MAE (20.1 against 21.53) tab. 2, and Cross-scene with lower per-scene MAE on S4 and S5 tab. 3. The authors attribute the S4 gap to the detector working poorly on remote crowds §5.4.
  • Missing details. Optimizer momentum, weight decay, batch size, the pretraining of the Faster R-CNN backbone, and the validation metric are not stated.

Lineage

  • Builds on: Faster R-CNN [ren2015faster] for the detection branch §3.3, and Gaussian-kernel density-map ground truth, as used in the cited density regression work [onoro2016towards] §3.1.
  • Compared against: detection baselines (R-FCN, Faster R-CNN, SquareChn) and regression baselines (M-CNN, Switching-CNN, CP-CNN, Cross-scene, FCN) §5.2–§5.4.
  • Superseded by: not stated in this wiki.

Source and license

Adapted from “DecideNet: Counting Varying Density Crowds Through Attention Guided Detection and Density Estimation” by Jiang Liu, Chenqiang Gao, Deyu Meng, Alexander G. Hauptmann (arXiv:1712.06679), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.