LiteRaceSegNet
A small CNN that segments road damage (potholes) as a binary mask. The full model has about 0.125M parameters. I wanted to see how much of the small damage regions and their edges a model this size can keep.
Model
Code: seg/core/lightweight_race.py
| Stage | Layers | Channels | Scale |
|---|---|---|---|
| stem | 3×3 conv (stride 2) + depthwise separable conv | 24 | 1/2 |
| detail | LiteIRBlock × 2 | 24 | 1/2 |
| down1 | LiteIRBlock × 2 (stride 2) | 48 | 1/4 |
| down2 | LiteIRBlock × 2 (stride 2) | 96 | 1/8 |
| context | LiteASPP (dilation 1, 2, 4 + global pooling) | 96 | 1/8 |
| boundary head | edge logit from the detail and context features | 1 | 1/2 |
| fuse | detail, context and edge logit concatenated and fused | 96 | 1/2 |
| head | 1×1 conv, then upsampled to the input size | 2 | 1 |
| aux head | 1×1 conv on the down1 output (training only) | 2 | 1 |
LiteIRBlock is a simplified version of the MobileNetV2/V3 inverted-residual block, written for this project.
The boundary head predicts an edge logit from the detail features and the upsampled context features. The detail features are multiplied by 1 + sigmoid(edge) (boundary gate), and the edge logit goes into the final fusion as one extra channel (boundary-logit fusion).
Training setup
| Input size | 256 × 384 |
|---|---|
| Batch / epochs | 4 / up to 60, early stopping with patience 12 |
| Optimiser | AdamW, lr 3.2e-4, weight decay 2e-4, poly schedule |
| Loss | CE 1.0 + Dice 0.35 + auxiliary 0.2 + boundary 0.1 |
| Data | 2,400 training pairs, 10 validation pairs, 10 test images |
| Hardware | AWS GPU instance, AMP, seed 42 |
Config: seg/config/v13_ablation/v13_full_reference.yaml
Results
All numbers are from final_evidence/. Each variant was trained once.
Ablation (10 validation images)
| Variant | mIoU | Damage IoU | Δ mIoU | Params (M) | Latency (ms) | Best epoch |
|---|---|---|---|---|---|---|
| Full model | 0.8072 | 0.7113 | — | 0.1245 | 3.10 | 2 |
| No detail branch | 0.7982 | 0.6984 | −0.0090 | 0.1245 | 2.67 | 2 |
| No boundary gate | 0.8010 | 0.7023 | −0.0063 | 0.1245 | 3.05 | 2 |
| No boundary-logit fusion | 0.8046 | 0.7078 | −0.0026 | 0.1245 | 3.11 | 2 |
| LiteASPP replaced by two DSConv layers | 0.7850 | 0.6784 | −0.0222 | 0.1235 | 2.76 | 2 |
| No auxiliary head/loss | 0.7919 | 0.6866 | −0.0153 | 0.1244 | 3.03 | 11 |
| Slim backbone (16 / 64 channels) | 0.8064 | 0.7095 | −0.0008 | 0.0594 | 3.12 | 20 |
Latency is per image on CUDA with a 256×384 input. Validation threshold 0.60.
The validation set is 10 images and each variant was trained once, so small gaps such as the 0.003 for boundary-logit fusion should not be read as real effects. The larger drops come from removing LiteASPP and the auxiliary loss. The slim backbone has less than half the parameters and almost the same mIoU.
Threshold (10 validation images)
| Threshold | Min area | mIoU | Damage IoU | Precision | Recall |
|---|---|---|---|---|---|
| 0.60 | 120 px | 0.8073 | 0.7113 | 0.918 | 0.759 |
| 0.75 | 30 px | 0.8006 | 0.6984 | 0.951 | 0.724 |
0.60 is used for the quantitative comparison; the test inference and the figure below use 0.75.
Test (10 images, threshold 0.75)
| Damage IoU | Dice | Precision | Recall | Boundary F1 |
|---|---|---|---|---|
| 0.662 | 0.795 | 0.963 | 0.681 | 0.058 |
Patches along the boundary
1,280 patches each of 32×32 and 64×64 were cut at ground-truth boundary pixels, and the same metrics were computed inside them.
| Patch | IoU | Dice | Precision | Recall |
|---|---|---|---|---|
| 32×32 | 0.231 | 0.375 | 0.795 | 0.245 |
| 64×64 | 0.341 | 0.508 | 0.901 | 0.354 |
| All 2,560 | 0.321 | 0.486 | 0.886 | 0.335 |
The model finds the damaged area but loses much of its edge.
SegFormer-B3 training scripts are included in seg/transformer_b3/ as a comparison baseline. Its results are not recorded in this repository.
Inference output
Boundary lines only · Summary cards · Raw and post-processed masks
The summary cards are made by seg/infer_service_visual.py, which computes the damaged-area ratio and the number of regions from each mask.
Run
pip install -r requirements.txt python scripts/smoke_check_literace.py # builds the model and runs a forward pass python seg/train_literace.py --config seg/config/pothole_binary_literace_train.yaml bash scripts/run_v13_ablation_matrix.sh # trains the 7 variants and writes the summary
Training needs your own image and mask pairs laid out as described in datasets/pothole_binary/README_DATASET_LAYOUT.md. The .bat files in the root do the same steps on Windows.
Layout
seg/core/ model, data loading, training utilities seg/config/ training configs, v13_ablation/ for the 7 variants seg/tools/ profiling, ablation summary, boundary metrics scripts/ smoke check, ablation and evidence pipelines final_evidence/ recorded results: ablation, threshold, test inference, metrics, case split index.html, ko/, en/ this page
License
Not an open-source license. The code and documents are public for viewing and academic reference only; see LICENSE. The dataset, checkpoints and trained weights are not included. Third-party components keep their own licences (THIRD_PARTY_NOTICES.md).