YOLO26s — Serial Number Bounding Box
Fine-tuned YOLO26s (small) that detects the serial number (the digit string printed on the product) in industrial meter photos. One bounding box per serial number, ready to be cropped and fed to an OCR step.
Resumo (pt-BR): modelo YOLO26s treinado para detectar a bounding box do número de série em fotos de medidores. Dataset
nuven-mira/serial-number-bbox-v1.0(8695 imagens rotuladas manualmente). Split 80/10/10 com seed 42 (6956/869/870). mAP50 = 0.975 · mAP50-95 = 0.798 no teste. O melhor limiar de confiança para operar é 0.39 (F1 = 0.971). Como foi treinado e como replicar está tudo na seção Training abaixo.
| Architecture | YOLO26s (Ultralytics, 260 layers) |
| Parameters / GFLOPs | 9,948,638 / 22.7 |
| Classes | 1 — serial_number |
| Input | images (trained at 640 px, native 480×640) |
| Weights | yolo26s_serial-small-10-11-26.pt (20.3 MB, FP32) |
| Base checkpoint | yolo26s.pt pretrained on COCO |
| mAP50 / mAP50-95 (test) | 0.9748 / 0.7980 |
| Recommended confidence | 0.39 (max F1) · 0.25 if you prefer higher recall |
| Speed (RTX 3050, batch 1) | 10.7 ms/img ≈ 93 FPS |
Dataset
Trained on nuven-mira/serial-number-bbox-v1.0:
8695 field photos of electricity meters (480×640), 8696 human-annotated
bounding boxes (Label Studio, one-by-one), YOLO format, CC BY 4.0.
The dataset is flat (no official split) — the split below was created for
this training.
Training (replicable)
Split — 80/10/10, seed 42
Deterministic, created by split_dataset.py:
- collect stems (filenames without extension) that have both image and label, sorted alphabetically;
random.Random(42).shuffle(stems);- cut 80% / 10% / 10% (
int(n*0.8),int(n*0.1), rest);
| Split | Images | Boxes |
|---|---|---|
| train | 6956 | 6957 |
| val | 869 | 869 |
| test | 870 | 870 |
Byte-identical duplicates (md5) are forced into the same split with a
deterministic swap (0 duplicates found in this dataset). The exact file list
of each split is committed in split_manifest.json —
that file is the source of truth to replicate or audit the division.
Hyperparameters
| Parameter | Value | Note |
|---|---|---|
| base checkpoint | yolo26s.pt | COCO pretrained |
| epochs | 100 | with early stopping |
| patience | 30 | stopped at epoch 91, best epoch 61 |
| imgsz | 640 | |
| batch | 16 | fits RTX 3050 8 GB |
| workers | 2 | |
| seed | 42 | deterministic=True |
| optimizer | MuSGD (auto), lr=0.01, momentum 0.9 | optimizer=auto |
| AMP | enabled | |
| cache | False |
Total wall time ≈ 4.3 h on a single NVIDIA RTX 3050 8 GB (training was
interrupted once and resumed exactly from last.pt with resume=True).
Environment: Python 3.10.12 · Ultralytics 8.4.184 · PyTorch 2.11.0+cu128.
Reproduce from scratch
# 1. dataset (flat: images/ + labels/)
hf download nuven-mira/serial-number-bbox-v1.0 --repo-type dataset --local-dir datasets/serial-number-bbox-v1.0
# 2. split (seed 42, 80/10/10) -> datasets/serial-number-bbox-split/ + data.yaml
python split_dataset.py
# 3. train (early stopping; save_dir holds best.pt / last.pt)
yolo detect train model=yolo26s.pt data=datasets/serial-number-bbox-split/data.yaml \
epochs=100 imgsz=640 batch=16 workers=2 seed=42 deterministic=True patience=30
# 4. evaluate on the test split
python metrics_report.py --split test
(The split_dataset.py / metrics_report.py scripts used live in the
experiment folder of the training repository, see Links.)
Metrics (test split — 870 unseen images)
Matching TP/FP at IoU ≥ 0.5 (greedy, by descending confidence).
| Metric | Value |
|---|---|
| mAP50 | 0.9748 |
| mAP50-95 | 0.7980 |
| AP50 / AP75 / AP50-95 (101-pt COCO) | 0.9737 / 0.8323 / 0.7947 |
| Precision / Recall (Ultralytics val) | 0.9662 / 0.9678 |
| Confidence at max F1 | 0.39 |
| P / R / F1 @ 0.39 | 0.9702 / 0.9724 / 0.9713 |
| TP / FP / FN @ 0.39 | 846 / 26 / 24 |
| ECE (calibration) | 0.1119 |
| Latency (RTX 3050, batch 1) | 10.7 ms/img ≈ 93 FPS |
Operating threshold
| Threshold | Precision | Recall | F1 | TP | FP | FN |
|---|---|---|---|---|---|---|
| 0.25 | 0.9230 | 0.9782 | 0.9498 | 851 | 71 | 19 |
| 0.50 | 0.9744 | 0.9621 | 0.9682 | 837 | 22 | 33 |
| 0.39 (max F1) | 0.9702 | 0.9724 | 0.9713 | 846 | 26 | 24 |
Confidence distribution (conf ≥ 0.25)
| Set | n | mean | median | std | p10 | p90 |
|---|---|---|---|---|---|---|
| All detections | 922 | 0.797 | 0.854 | 0.161 | 0.575 | 0.929 |
| TPs | 851 | 0.827 | 0.868 | 0.114 | 0.668 | 0.929 |
| FPs | 71 | 0.438 | 0.335 | 0.204 | 0.271 | 0.821 |
FPs sit at much lower confidence than TPs (median 0.33 vs 0.87) — threshold 0.39 separates the two groups well.
Localization quality (846 TPs @ conf ≥ 0.39)
| Metric | mean | median | p10 | p90 |
|---|---|---|---|---|
| IoU | 0.8915 | 0.9425 | 0.7171 | 0.9808 |
| Center error (px) | 2.29 | 0.86 | 0.26 | 4.38 |
| Relative width error | 2.9% | 0.9% | 0.1% | 7.4% |
| Relative height error | 7.6% | 3.5% | 0.6% | 21.4% |
Robustness
| GT box size (area quartile) | GT | Recall |
|---|---|---|
| Q1 (smallest, < 3610 px²) | 218 | 0.9771 |
| Q2 | 217 | 0.9770 |
| Q3 | 217 | 0.9770 |
| Q4 (largest) | 218 | 0.9587 |
- 97.2% of images with perfect recall (every GT detected)
- 0% of images with zero detections · 3.0% with ≥1 FP (0.03 FP/image)
Why mAP50-95 (0.80) < mAP50 (0.97)
Detection is not the issue (recall 0.97); strict localization is. AP by IoU threshold:
| IoU ≥ | 0.50 | 0.55 | 0.60 | 0.65 | 0.70 | 0.75 | 0.80 | 0.85 | 0.90 | 0.95 |
|---|---|---|---|---|---|---|---|---|---|---|
| AP | 0.974 | 0.965 | 0.955 | 0.930 | 0.884 | 0.832 | 0.775 | 0.688 | 0.587 | 0.358 |
Boxes are thin (median ≈ 152×33 px), where a few pixels of border offset cost a lot of IoU, and human annotation tightness varies (some GTs include the barcode). Median IoU 0.94 and median center error 0.9 px are the practical quality figures for an OCR crop.
Full machine-readable metrics: metrics/test/report.json.
How to use
from ultralytics import YOLO
model = YOLO("yolo26s_serial-small-10-11-26.pt")
res = model.predict("meter_photo.jpg", imgsz=640, conf=0.39)[0]
for box in res.boxes:
x1, y1, x2, y2 = box.xyxy[0].tolist() # serial number box, pixels
conf = float(box.conf[0])
Or with hf_hub_download:
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
path = hf_hub_download("nuven-mira/yolo26s-serial-small-10-11-26",
"yolo26s_serial-small-10-11-26.pt")
model = YOLO(path)
Limitations
- Photos through dirty/reflective glass with the digits barely visible are the hardest cases (some FPs/FNs concentrate there).
- Trained on meter front-panel photos (field capture); other product types or heavy domain shifts may need fine-tuning.
- One box per serial number; reading the digits is a separate OCR step.
Links
- Dataset: nuven-mira/serial-number-bbox-v1.0
- Training experiment (scripts + full report):
experiments/serial-number-bbox/in the nuven-mira/mira-ia-lab training repository (split_dataset.py,train_yolo26s.py,metrics_report.py,export_test_outputs.py,README.md) - Previous serial detector: nuven-mira/yolo26s-serial-small-02-10-26
License
CC BY 4.0 — same as the training dataset.