TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

U-Net and HRNet: Resolution-Preserving Architectures and Heatmap Output

Status: Draft (2026-10-13), partially measured. The examples in Sections 1 and 4 are values run directly on a laptop CPU (code/03_heatmap.py, 3 seconds). Paper figures are transcribed from the original texts along with their conditions. Measurements for the ball-tracking model are cited from TT Score Model Anatomy Part 2. Writing Rule: Measured data is the default; anything unmeasured is marked as "Unmeasured."

Table of Contents

1. Classification Shrinks, Location Must Be Preserved

In Part 1, we mentioned that pooling broadens the receptive field while blurring locations. Let's see how much blurring actually occurs. We drew a 3px-diameter ball on a 32×32 image and applied repeated 2×2 average pooling (measured).

Resolution Size Remaining Ball Pixels (Value > 0.25) Brightest Pixel
1 32×32 7 1.00
1/2 16×16 2 1.00
1/4 8×8 1 0.31
1/8 4×4 0 0.08
1/16 2×2 0 0.02

At 1/8 resolution, the ball is nearly indistinguishable from the background. This means that in the deep layers of classification models (ResNet typically shrinks down to 1/32), the precise location of the ball no longer remains. However, deep layers possess a broad context to determine "is this a ball?" An architecture that simultaneously possesses context (deep and wide view) and location (shallow and detailed view)is required. The answer branches into two directions.

해상도를 지키는 두 방법 U-Net: 줄였다가 키우고, 같은 층끼리 잇는다 인코더(줄이기) 디코더(키우기) 점선 = 건너뛰기 연결: 줄이기 전의 세밀한 위치를 디코더에 다시 준다 HRNet: 고해상도 갈래를 끝까지 둔다 1/4 1/8 1/16 1/32 세로 화살표 = 여러 해상도를 계속 섞는다 출력 히트맵은 가장 위(1/4) 갈래에서 나온다 둘 다 「작은 물체의 정확한 위치」를 잃지 않으려는 설계다. 공 찾기의 WASB·BlurBall 은 HRNet 쪽이다.
Figure: U-Net shrinks and enlarges while connecting corresponding layers, whereas HRNet maintains a high-resolution stream to the end and blends multiple resolutions.

2. U-Net (2015): Shrink, Enlarge, and Connect Corresponding Layers

Ronneberger et al. created U-Net for the segmentation of microscopic cell images (painting every pixel as either "cell" or "background"). True to its name, it has a U shape.

ResNet's shortcut in Part 2 addsvalues, whereas U-Net's skip connection concatenatesthem. Addition slightly modifies existing information, while concatenation places different kinds of information (position and meaning) side by side for the next layer to blend.

Mechanisms for Training with Limited Data

Medical images have expensive labels. The training data in the paper consisted of about 30 electron microscopy segmentation images (512×512) and 35/20 cell tracking challenge images. Therefore, the design is tailored to data conservation.

Results (Paper): Ranked 1st in the electron microscopy segmentation challenge with a warping error of 0.000353 (previous best 0.000420). IoU 0.9203(2nd place 0.83) and 0.7756(2nd place 0.46) on the two datasets of the 2015 Cell Tracking Challenge. Segmenting a 512×512 image took under a second on GPUs of that era, and training took 10 hours on a desktop GPU with 6GB of memory.

Beyond medical imaging, U-Net has become the baseline for almost any task requiring "producing a map of the same size as the input." TrackNetV2 for table tennis ball tracking also uses a U-Net architecture (TT Score Model Anatomy Part 2).

3. HRNet (2019): Keeping High Resolution to the End

U-Net shrinks once and then enlarges again. Although skip connections restore the positional information lost during shrinking, the high-resolution features received by the decoder belong to shallow layersand thus have weak semantic meaning. Sun et al. took a different path for human pose estimation (finding the locations of 17 joints). Maintaining a high-resolution stream from the beginning to the endis the core concept.

As a result, the high-resolution stream continuously receives semantic information from deep layers without losing resolution.

Model (COCO Pose, Validation Set) Input AP Parameters GFLOPs
SimpleBaseline(ResNet-152) 256×192 72.0 68.6M 15.7
HRNet-W32 (No pre-training) 256×192 73.4 28.5M 7.10
HRNet-W32 (ImageNet pre-trained) 256×192 74.4 28.5M 7.10
SimpleBaseline(ResNet-152) 384×288 74.3 68.6M 35.6
HRNet-W48 384×288 76.3 63.6M 32.9

(Paper Table 1. AP is the average joint location accuracy across multiple thresholds.) On the test-dev set, HRNet-W48 384×288 achieved 75.5. The main point of this table is that, with the same input, it is more accurate while having fewer parameters and computations than SimpleBaseline. "Not discarding resolution" proved to be more efficient than "discarding and recovering resolution."

4. Heatmap: Drawing a Map Instead of Coordinates

Both U-Net and HRNet output a map. For segmentation, it is a heatmap colored with the "probability of being an object" per pixel; for pose and ball detection, it is a heatmap colored with the probability of a joint (or ball) being presentper pixel. The ground truth is also created as a map. A small Gaussian hill is drawn at the joint location, and the Mean Squared Error (MSE) against the predicted map is measured per pixel. Stacked Hourglass (2016) used a hill with a standard deviation of 1px, the HRNet paper also mentions 1px, and the official configuration file uses σ=2. The output resolution is 1/4 of the input (256×192 → 64×48) based on the official HRNet configuration.

Trying It Out: Converting Heatmaps Back to Coordinates

Heatmaps ultimately need to be converted into coordinates to be useful. There are two methods.

  1. argmax: The location of the brightest cell. It is simple, but an error up to the cell size remains.
  2. Weighted centroid: A weighted average of the values of the cells exceeding a threshold (half of the maximum value). This restores the inter-cell position (sub-pixel accuracy).

Gaussian hills with σ=2 cells were drawn at 2,000 random locations in a 256×256 image, and the original coordinate errors were measured by decoding them at various heatmap strides (the reduction factor relative to the original) (measured values, ideal noise-free case).

Stride Heatmap Size Argmax Average Error Weighted Centroid Average Error
1 256×256 0.37px 0.05px
2 128×128 0.77px 0.10px
4 64×64 1.53px 0.20px
8 32×32 3.05px 0.40px

Two things can be observed. First, the argmax error is directly proportional to the stride. Reading a 1/4-resolution heatmap with argmax simply loses an average of 1.5px. Second, the weighted centroid reduces the error by a factor of 7 to 8. Therefore, pose estimation code applies post-processing such as an argmax adjustment moving 1/4 of a cell toward the neighboring cell, and WASB for ball detection uses the weighted centroidof the blob. However, real heatmaps contain noise and secondary peaks (such as a fake ball from a fluorescent light), so they are not as clean as this table.

5. Limitations

6. Connection to Our Project

Ball detection in TT Score directly follows the lineage of this post (TT Score Model Anatomy Part 2).

The next post covers how these maps are scored and trained, detailing the loss functions and training techniques.

TT Note. Reducing to 1/8 makes the ball disappear. That is why the ball detection model keeps the large map all the way. It is heavy, but better than missing the ball.

References

Sign in to like

Comments

No comments yet.

Sign in to leave a comment