Weld inspection is a textbook industrial computer-vision problem. An inspector looks at a seam, finds the weld bead and the base metal, spots any surface anomaly and decides whether the part passes. The first three steps are perception; the last one is a standards question.

This project trains a YOLO11x detector to do the perception part: localise the weld line, the workpiece, porosity and generic defects in a single pass. It is a research prototype, not a certified inspection system, but the validation report is honest enough to be useful.

What the model actually sees

Four classes, in this order:

IDClassMeaning
0DefectGeneric weld defect
1Welding LineWeld bead / seam
2WorkpieceBase metal part
3porosityPorosity

The checkpoint is deliberately large: 56.8 M parameters and 194.4 GFLOPs. For offline or semi-automated inspection, accuracy is worth more than the last few milliseconds of latency. A smaller variant makes sense only after the dataset matures.

Label distribution in the welding dataset

The numbers, and what they mean

On a validation split of 116 images / 773 instances:

ClassPrecisionRecallmAP@50mAP@50-95
all0.8260.8270.8420.632
Defect0.5520.4270.4450.202
Welding Line0.8730.9660.9660.679
Workpiece0.9410.9870.9920.938
porosity0.9390.9270.9650.710

Training results and F1 curve

The headline 0.842 mAP@50 is carried by the structural classes. Workpiece (0.992) and Welding Line (0.966) are almost solved; porosity (0.965) is surprisingly strong. The generic Defect class reaches only 0.445 mAP@50 and 0.427 recall — it groups cracks, undercuts, spatter and lack-of-fusion, which look nothing alike. That is the real research problem, not the architecture.

Normalised confusion matrix

A second caveat: 116 validation images is small. These numbers are a baseline for further work, not a production acceptance test.

Demo: sample predictions

These are validation predictions from the published checkpoint, not live inference:

Validation batch: model predictions

The boxes on the seam and the part are the model’s localisation output. To run the model yourself, the weights live on a gated Hugging Face model card — accept its conditions and authenticate first:

hf download jparedesDS/welding-defects-detection \
  welding_defects_yolo11x.pt --local-dir weights
from ultralytics import YOLO

model = YOLO("weights/welding_defects_yolo11x.pt")
results = model.predict("weld.jpg", conf=0.25, save=True, device=0)

for box in results[0].boxes:
    print(model.names[int(box.cls)], float(box.conf), box.xyxy.tolist())

Open the model on Hugging Face · Read the full project in the model zoo

From boxes to an inspection decision

The detector emits boxes, not verdicts. A usable pipeline adds four steps:

  1. Region filtering — keep defect boxes that fall on or near the detected Welding Line.
  2. Size measurement — convert box dimensions to millimetres with a calibrated capture rig.
  3. Rule engine — compare defect type and size with the applicable acceptance standard.
  4. Human review — route borderline or low-confidence cases to a qualified inspector.

Standards such as ISO 5817, ASME IX or AWS D1.1 define acceptance; a neural network does not. The model only makes the inspector faster.

What is next

  • Split Defect into cracks, undercuts, spatter and lack-of-fusion, and collect more examples per type.
  • Add pixel-level segmentation for defect sizing.
  • Calibrate distance, angle and lighting so box sizes mean something physical.
  • Validate against one specific standard and process before claiming readiness.

The original repository is archived; the code, notebook and evaluation now live in the object-detection-models zoo. MIT licensed.