Steel Defect Segmentation (YOLO26s-seg)

Instance segmentation model for steel surface defects (4 defect classes), fine-tuned from Ultralytics YOLO26 (yolo26s-seg) on the Severstal: Steel Defect Detection Kaggle dataset.

Full training/evaluation pipeline, conversion scripts, and a Gradio demo are in the source repo: https://github.com/tun0000/steel-defect-segmentation

Try it live: https://huggingface.co/spaces/betty0/steel-defect-segmentation

Why this matters for steel / manufacturing quality inspection

Manual visual inspection of steel strip surfaces is slow, inconsistent between inspectors, and hard to scale to full production-line speed. Instance segmentation β€” as opposed to plain classification or bounding-box detection β€” recovers the actual defect shape and area, which is what quality control needs to judge severity and to feed downstream metrics like defect area per coil. An end-to-end, NMS-free model like YOLO26-seg keeps per-image latency low enough (single-digit milliseconds on GPU, see below) for inline inspection.

Training data

12,568 grayscale 1600x256 images, RLE instance masks, 4 defect classes, severely imbalanced (defect_3: 4,636 training images vs. defect_2: 222). Full conversion pipeline (RLE decode, instance splitting, stratified split) is in the source repo's scripts/convert_severstal_to_yolo.py. Kaggle competition rules do not permit redistributing the raw data, so it is not included in this model repo β€” download it yourself from Kaggle (free, requires accepting the competition rules).

Results

Held-out validation split (734 images, seed 42), imgsz=1024:

mask mAP50 mask mAP50-95 GPU latency (RTX 4090, ONNX) CPU latency (ONNX)
0.587 0.232 8.04 ms mean (p95 8.46 ms) 167.39 ms mean (p95 179.35 ms)
class mask mAP50 mask mAP50-95
defect_1 0.537 0.173
defect_2 0.543 0.181
defect_3 0.625 0.260
defect_4 0.642 0.316

Class imbalance, honestly: instance count alone doesn't predict per-class difficulty. defect_2 β€” the rarest class in training β€” outperforms defect_1 (~10x more training instances) on mask mAP50-95. defect_1's defects tend to be thin, elongated scratches with ambiguous boundaries, which likely hurts mask IoU regardless of how much data it has.

Files

  • steel_defect_yolo26s_seg_best.pt β€” PyTorch checkpoint (Ultralytics format)
  • steel_defect_yolo26s_seg_best.onnx β€” ONNX export (NMS-free, end-to-end), used for the CPU-friendly Gradio demo

How to use

pip install ultralytics huggingface_hub
from huggingface_hub import hf_hub_download
from ultralytics import YOLO

weights = hf_hub_download("betty0/steel-defect-segmentation", "steel_defect_yolo26s_seg_best.pt")
model = YOLO(weights)
results = model.predict("steel_surface.jpg", imgsz=1024)
results[0].plot(pil=True).show()

For the ONNX file, pass task="segment" explicitly β€” a bare .onnx (no Ultralytics .pt metadata) can't always auto-detect the task and otherwise silently falls back to detection-only output with no masks:

model = YOLO(hf_hub_download("betty0/steel-defect-segmentation", "steel_defect_yolo26s_seg_best.onnx"), task="segment")

License

The training/conversion/demo code in the source GitHub repo is MIT licensed. These weights are fine-tuned from Ultralytics YOLO26, which Ultralytics distributes under AGPL-3.0 (or a commercial Enterprise license) β€” see Ultralytics' licensing terms before using these weights in a closed-source product. The training data is subject to the Severstal competition rules.

Downloads last month
30
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using betty0/steel-defect-segmentation 1