IE7615 · Neural Networks & Deep Learning · Revival

Thermal Image
Segmentation and
Annotation

The Fall 2020 project, re-run with honest metrics, a modern training recipe and cross-dataset pseudo-labels.
By: Vipul V Suresh
Original: 12/10/2020 · Revival: November 2026
16 32 64 128 256 128 64 32 16
U-Net · 16 → 256 filters

Contents

01Problem
02Approach
03Datasets
04Ground truth
05Model
06Experiments
07Results
08Conclusion
09What's next

Problem

  • The metric couldn't see failure. The 2020 notebook's pixel accuracy sat at 78.4–78.7% for all 43 epochs while its loss kept falling. On KAIST, an empty mask scores 99%.
  • The loss rewarded predicting nothing at first. Plain BCE on KAIST predicted no foreground for 12 epochs.
  • NUANCE labels are heuristic. Its masks come from intensity thresholds, not people drawing outlines.
Stage 0 on KAIST · same model, same data
Epochs 1–11 · pixel accuracy
0.99 Epochs 1–11 · IoU
0.00 Final · pixel accuracy
0.994 Final · IoU
0.546
Epochs 1–11 from the validation curves; final values on the test set. Pixel accuracy barely moves while IoU goes from 0 to 0.55.
Overlap of prediction and label
G labelled P predicted P ∩ G Background: most of the frame, ignored by IoU and Dice
IoU|P ∩ G| ÷ |P ∪ G|
Dice2|P ∩ G| ÷ (|P| + |G|)
An empty prediction has P ∩ G = 0, so it scores 0 on both, however much background it gets right.

What is segmentation

  • Pixel-level labelling of the classes in an image
  • The output is not a number or a bounding box. It is an image the same size as the input.
  • Here it is binary: obstacle (pedestrian or vehicle) vs. background
  • Scored with IoU and Dice, which measure overlap with the labelled mask

Why thermal imaging

body heat peaks ≈ 9.4 µm Visible Near IR Short-wave IR Mid-wave IR mostly absorbed Long-wave IR 0.4 0.7 1.4 3 5 8 14 µm RGB cameras Thermal cameras
Wavelength on a log scale. A body at 37 °C radiates most strongly near 9.4 µm (Wien's law), inside the 8–14 µm band seen by long-wave thermal cameras such as the FLIR Boson used for NUANCE.
  • It reads emitted heat, so it works in darkness and headlight glare
  • It backs up RGB cameras in ADAS when lighting fails
  • Segmentation localizes obstacles, which helps scene understanding
  • Uses: ADAS, industrial inspection, law enforcement, medical imaging

Approach

Pedestrians and vehicles are merged into one obstacle class. Each stage changes one thing, so every row of the ablation can be explained.
Stage 0
Honest baseline
The 2020 U-Net and BCE loss, with a 70:15:15 split and IoU / Dice on the test set
Stage 1
Loss + augmentation
BCE + Dice loss, Albumentations, AdamW with cosine warm restarts
Stage 2
Pretrained encoder
SMP U-Net with an ImageNet ResNet-18 encoder and two-phase fine-tuning
Stage 3
Pseudo-labels
Relabel NUANCE with the KAIST-trained Stage 2 model, then retrain

Datasets

KAIST Multispectral Pedestrian

1,702image–mask pairs
0.99%pixels foreground
0%frames with no foreground
  • Masks drawn by hand (Ghose et al., 2019) [2]
  • Split 1,190 / 256 / 256

NUANCE autonomous car

1,806frames (every 20th of 36,120)
17.9%pixels foreground
9.5%frames with no foreground
  • FLIR Boson camera on Northeastern's NUANCE car, Boston
  • No manual labels: K-means + threshold masks mark everything warm
  • Split 1,264 / 271 / 271
[2][3][7]

Ground truth for NUANCE

2020 · methods compared
  • Otsu threshold
  • Global threshold + K-means clean-up
  • To-zero threshold + binary filter, chosen by inspection
  • Canny edges
2026 · Stage 3 pseudo-labels
  • Thresholds mark everything warm: facades, parked cars, the car's own hood
  • The KAIST Stage 2 model relabels each frame: >0.75 → obstacle, <0.25 → background, otherwise keep K-means
What each mask set marks as foreground
Pixels marked foreground (0–20%)Frames with none (0–20%) KAIST · hand-drawn
0.99%
0% NUANCE · K-means (2020 recipe)
17.9%
9.5% NUANCE · refined (Stage 3)
0.49%
18.8%
Measured over all frames of each dataset. The refined set keeps only the KAIST model's confident pixels, and on NUANCE it was confident mostly about background.

Model
implementation

Custom U-Net (Stages 0–1) · SMP U-Net + ResNet-18 (Stages 2–3)

U-Net architecture

16 32 64 128 256 128 64 32 16 1×128×128 in 1×128×128 mask skip connections max-pool ↓ · transposed conv ↑ · numbers = filters
Custom U-Net: two 3×3 conv + BN + ReLU per block, dropout 0.05.
Stages 0–1 Stages 2–3
ModelCustom U-NetSMP U-Net
EncoderRandom initResNet-18, ImageNet
Parameters2.16 M14.3 M (11.2 M encoder)
Input1×128×1281×128×128, batch 8
LossBCE (S0) · BCE+Dice (S1)BCE+Dice
ScheduleS1: AdamW + cosine warm restarts (T₀ 10, ×2)10 epochs encoder frozen (LR 1e-3), then encoder 1e-5 / decoder 1e-4
The 1-channel input reuses the averaged RGB stem weights. EfficientNet-B0 and scSE attention ran out of memory on CPU; ResNet-18 without attention fit.
[1][5]

Experiment steps

1
Stage 0 baseline
BCE, no augmentation, on KAIST and NUANCE
train_stage0.py --dataset kaist
2
Stage 1 recipe
BCE + Dice, Albumentations, AdamW
train_stage1.py --dataset nuance
3
Stage 2 encoder
ResNet-18, frozen for 10 epochs, then fine-tuned
train_stage2.py --no-attention
4
Pseudo-label NUANCE
KAIST Stage 2 relabels 1,806 frames, 99.7% of pixels confident
refine_masks.py --preview 10
5
Retrain on new labels
Stage 2 on NUANCE with the refined masks
--annos-dir Annos_refined --ckpt-suffix _refined
6
Evaluate
Ablation table and qualitative grids from the best checkpoints
evaluate.py --dataset kaist
7 training runs CPU only, Windows 11, one run at a time to fit in RAM Early stopping: val loss (S0), val IoU (S1–3) Seed 42 · test-set metrics

Results

7 runs · test-set IoU, Dice, recall, precision
0.804
Best NUANCE IoU
Stage 0 (BCE)
0.546
Best KAIST IoU
Stage 0 (BCE)
0.758
NUANCE IoU
Stage 2 (ResNet-18)
0.505
NUANCE IoU
Stage 2, pseudo-labels

Ablation: all seven runs

Ablation table of seven runs with IoU, Dice, recall, precision and pixel accuracy
KAIST · Stage 0
0.546 KAIST · Stage 1
0.506 KAIST · Stage 2
0.495 NUANCE · Stage 0
0.804 NUANCE · Stage 1
0.732 NUANCE · Stage 2
0.758 NUANCE · Stage 2, pseudo
0.505
KAISTNUANCE (K-means masks)NUANCE (pseudo-labels)IoU, axis 0–1
  • Stage 0 is best on both datasets
  • Stage 2 recovers on NUANCE (+0.026 over Stage 1), not on KAIST
  • Pixel accuracy is highest (0.997) for the run with the lowest IoU

Why pixel accuracy misleads

Stage 0 training · KAISTvalidation curves
Stage 0 KAIST curves: BCE loss falls smoothly; IoU and Dice stay at zero until about epoch 12, then rise to 0.54 and 0.70; pixel accuracy is near 0.99 from epoch 1
LossBCE falls smoothly from the first epoch. Nothing here signals a problem.
IoU & DiceBoth stay at 0.00 until about epoch 12, because the model predicts no foreground. They then climb to 0.54 / 0.70.
Pixel accuracyIt reads ≈ 0.99 from epoch 1, during the collapse. That is the trap in the 2020 metric.

Stage 2: two-phase fine-tuning

NUANCE · ResNet-18best epoch 62 · IoU 0.758
Stage 2 NUANCE curves across 77 epochs: loss falls, IoU rises to about 0.77 on validation, learning rate shows restarts at epochs 10, 30 and 70
KAIST · ResNet-18best epoch 23 · IoU 0.495
Stage 2 KAIST training curves with the same four panels
Blue band = Phase 1 (encoder frozen, 10 epochs). Green = Phase 2 (all layers, encoder LR 10× lower). The LR panel shows cosine warm restarts at epochs 10, 30 and 70 (NUANCE); KAIST stopped early at epoch 38. The stored plot titles say "EfficientNet-B0 / 256×256"; the runs used ResNet-18 at 128×128.

Metrics by stage: KAIST test set

0 0.25 0.50 0.75 1.00 .546.506.495 .706.672.662 .714.742.725 .698.614.610 IOUDICERECALLPRECISION
Stage 0 · BCEStage 1 · BCE+DiceStage 2 · ResNet-18
Trade-offBCE + Dice raised recall (0.714 → 0.742) but cut precision (0.698 → 0.614): more pixels flagged, more of them wrong.
EncoderThe pretrained ResNet-18 did not win precision back (0.610).
Net effectIoU falls from 0.546 to 0.495 across the stages.

Metrics by stage: NUANCE test set

0 0.25 0.50 0.75 1.00 .804.732.758 .892.845.862 .880.852.853 .904.838.872 IOUDICERECALLPRECISION
Stage 0 · BCEStage 1 · BCE+DiceStage 2 · ResNet-18
LeaderStage 0 is best on every metric.
EncoderStage 2 wins back precision over Stage 1 (0.838 → 0.872); recall stays near 0.85.
CaveatThese scores measure agreement with K-means masks that mark everything warm (17.9% of pixels), not true object accuracy.

Pseudo-labels did not transfer

The KAIST-trained model barely fires on NUANCE frames (a different camera and different scenes), so its pseudo-labels are nearly empty.
0.49%
pixels marked foreground
(K-means: 17.9%)
18.8%
frames with no
foreground at all
99.5%
pixel accuracy of an
all-empty prediction
0.9969
retrained model's pixel
accuracy, at IoU 0.505
Stage 2 retrained on pseudo-labels · NUANCEIoU 0.505 · pixel acc. 0.997
Stage 2 training on refined labels: IoU plateaus near 0.5 while pixel accuracy is flat at about 0.99 from epoch 0

Conclusion

  • Report IoU and Dice. Pixel accuracy read 0.99 while the model found nothing.
  • The simplest model (Stage 0) scored best: IoU 0.546 on KAIST and 0.804 on NUANCE
  • NUANCE is limited by its labels: K-means masks reward segmenting heat, not objects
  • KAIST pseudo-labels did not carry over to NUANCE's camera without domain adaptation
Stage 0 · KAIST validationIoU 0 for 12 epochs · pixel accuracy 0.99 throughout
IoU and Dice near zero for the first 12 epochs, while the pixel accuracy line sits near 0.99 from epoch 1

What's
next

  • Better NUANCE labels: SAM2 masks prompted with boxes taken from the K-means blobs
  • More thermal data: pre-train on FLIR's annotated ADAS thermal dataset
  • Resolution: test 256×256 on a GPU, then retry EfficientNet-B0 with scSE attention
  • Domain adaptation before pseudo-labeling: histogram matching first, then DANN
  • Beyond binary: SegFormer baseline and pedestrian / vehicle / road classes

References

  1. Ronneberger, Fischer & Brox (2015). U-Net: Convolutional Networks for Biomedical Image Segmentation. MICCAI. arXiv:1505.04597
  2. Ghose et al. (2019). Pedestrian Detection in Thermal Images Using Saliency Maps. CVPR Workshops.
  3. Hwang, Park, Kim, Choi & Kweon (2015). Multispectral Pedestrian Detection: Benchmark Dataset and Baseline. CVPR.
  4. Liu, Zhang, Wang & Metaxas (2016). Multispectral Deep Neural Networks for Pedestrian Detection. arXiv:1611.02644
  5. Iakubovskii, P. Segmentation Models PyTorch (v0.6.0). github.com/qubvel/segmentation_models.pytorch
  6. Buslaev et al. (2020). Albumentations: Fast and Flexible Image Augmentations. Information 11(2).
  7. NUANCE autonomous car dataset, Northeastern University (FLIR Boson, Boston).
  8. He, Zhang, Ren & Sun (2016). Deep Residual Learning for Image Recognition. CVPR.
  9. OpenCV thresholding tutorial: docs.opencv.org/3.4/db/d8e/tutorial_threshold.html
Turn your phone sideways for larger slides
← Portfolio
← → keys