← All posts

AI analysis of weld radiographs: from dataset to inspection system

AI for weld radiography: dataset, labels, detector, rules, and an expert. Why 88 GDXray images are not a plant dataset.

AI analysis of weld radiographs: from dataset to inspection system
Contents

Radiographic testing of a weld already produces a digital image. A discontinuity may occupy a dozen pixels on a multi-thousand-pixel frame. The cost of error is not an awkward UI: a missed crack or lack of penetration becomes a report, and the report becomes permission to operate equipment. AI belongs here as a helper for the NDT inspector, not as a “pass / fail” button.

This article is an engineering map: computer vision (CV) problem framing, dataset and labeling, the public GDXray Welds set, the roles of CNN, YOLO, segmentation, CRNN and ViT, a normative rules layer, and the expert interface. It is not a claim of a finished plant system and not a report with factory metrics. Labor figures are order-of-magnitude estimates, not a standard. The discipline is the same as in the handwritten UT form pilot and the CNN / CRNN digit path: task contract and data first, model second.

Key takeaways

The model does not decide acceptability. It proposes presence, class, location, and confidence. Code compliance is a separate rules layer plus the inspector.

The scarce resource is not the GPU, it is labeled radiographs with metadata. Without an expert report and object context, the network learns the stains of one film.

Naive resize kills small defects. A 4096 × 2048 frame must not be blindly squeezed to 640 × 640 if a discontinuity is 8 × 12 pixels. You need the weld region, overlapping tiles, and fused predictions.

Eighty-eight public GDXray Welds images are a bench for a proof of concept, not a plant sample. Series overlap, not every frame has labels, and the era of the equipment is not your shop floor.

A CNN with 5–30 million parameters is already a serious backbone. YOLO answers “what and where.” Segmentation is for area and geometry. CRNN is a hypothesis for a long weld, not a drop-in detector replacement.

The expensive error is a false negative: a real defect that was missed. False alarms waste inspector time; a missed discontinuity voids the point of inspection.

Split by weld or inspection before tiling. Otherwise neighboring tiles of one radiograph land in both train and test, and the metric lies.

Why radiographic weld inspection is a high-cost-of-error problem

Radiographic testing (RT) is one method of nondestructive testing (NDT). The result already lives as a digital image: a digitized film or a panel detector frame. Plants accumulate thousands to tens of thousands of such frames. A person reads each one; qualification drives completeness and stability of the report.

Automation is interesting not because “networks can do images,” but because volume grows faster than the pool of experienced inspectors, and the cost of a miss exceeds the cost of extra review. The same idea — test and automate in proportion to failure cost — is the core of testing economics. For a weld, failure is not a form bug; it is a discontinuity that may reach service.

What you look for depends on process, material, and code, but the usual discontinuity vocabulary is familiar: porosity, slag inclusions, lack of penetration, lack of fusion, cracks, undercuts, burn-through, and other flaws. Even at this step you must not collapse five contracts into one:

Contract Question Model output
Detection Is there a defect on the frame? GOOD / DEFECT or a probability
Classification Which type? a class or a distribution
Localization Where is it? a bounding box
Segmentation Which pixels? a mask
Measurement What size and shape? length, width, area, orientation
Acceptability Does the weld meet the code? not a model output — rules + expert

An AI that stamps “pass” mixes a statistical detector with a legally meaningful report. Codes speak in defect type, size, location relative to root and surface, and count per unit weld length. Those rules change with the standard and the contract, not with network weights. Keep the rules engine outside training: you can retrain on new images without rewriting ISO clauses and internal inspection maps.

Levels of difficulty: from a class to a code decision

Grow the problem in steps. Do not start with “automatic reports for the whole archive.”

Step one is binary: the frame is clean or it contains a defect. Cheap labels, an honest pilot: does any signal exist? Step two is a defect type for the whole image. It breaks as soon as one weld has both pores and an inclusion: a single image-level tag lies. Step three is coordinates: several objects on one frame, each with class and confidence. Step four is a pixel mask. Step five is measurements from the mask or the box. Step six is a draft report. Step seven is comparison with code thresholds.

A convolutional classifier looks simple: radiograph → CNN → class probabilities. You might see porosity 0.91, slag 0.04, crack 0.02, normal 0.03. The upside is speed, cheap labels, a clear baseline. The downside is no coordinates, no size, a fight when several defects share a frame, and high sensitivity to resize. For archival “skip the obviously clean” a classifier helps. For measurement and accept/reject it does not.

Object detection (YOLO and related detectors) answers three questions at once: what, where, how sure. The output is a list of boxes. That matches a weld radiograph: a string of pores, an inclusion nearby, an undercut on the toe. Box labels cost more than binary tags and still less than full masks. The weak spot is a tiny object on a huge frame, and a box that fits a long crack along the weld axis poorly.

Segmentation (U-Net, Mask R-CNN, modern mask models) yields a pixel contour. A box says “somewhere in this rectangle.” A mask says “these pixels.” Area, equivalent diameter, elongation, distance to the weld edge come from the mask, not the box. You pay with the most expensive labels: a polygon or a brush on every defect.

CRNN here is not optical character recognition (OCR) copied wholesale. In OCR the sequence is characters. On a weld the sequence is strips along the weld axis: convolutional features, then a GRU/LSTM looking at neighbors. That can catch weak elongated changes that look like noise on a single tile. It is an architectural hypothesis, not a detector replacement. We already walked CNN → sequence for handwritten digits; weld geometry does not drop into that checkpoint.

ViT splits the image into patches and binds them with attention. Global context helps when a defect is readable only relative to the whole weld. The price is data. On a small set a vision transformer trained from scratch learns film noise. Fine-tune a pretrained encoder and compare it with a CNN on an independent set; do not adopt it because it is fashionable in 2026.

How a weld radiograph breaks a naive pipeline

A typical industrial frame is not an ImageNet 224 × 224 square. Resolutions around 4096 × 2048 are common. A defect may be 8 × 12 pixels. If you downsample the whole image to a 640 × 640 detector input, the small object dies in averaging. The model honestly learns not to see what preprocessing already discarded.

A working scheme is different. Find the weld region first (a separate model or fixture geometry), then tile it. Choose a tile size so the defect remains an object, not a speck: often 1024 × 1024 or similar, with 20–30% overlap so an object on the border is not split in half. Stitch the answers: merge boxes from neighboring tiles, glue masks, drop duplicates. Resize still happens inside a tile, but the scale is different.

flowchart TB
  src[Radiograph]
  src --> roi[WeldROI]
  roi --> tiles[TilesWithOverlap]
  tiles --> det[CNN_or_YOLO]
  det --> stitch[StitchAndNMS]
  stitch --> out[DefectCandidates]

Dynamic range is the second trap. The source is often 12- or 16-bit: TIFF or DICOM, not “a JPEG from the viewer.” JPEG clips the histogram, adds compression artifacts, and can hide a low-contrast crack. Histogram normalization and controlled contrast enhancement belong in a reproducible pipeline step, not in “export from the viewer as JPG.” The rule is simple: do not convert a high-bit radiograph to JPEG unless you must. If labelers need an 8-bit preview, store the preview beside the original and train on native depth or a documented 16→8 conversion.

Artifacts are eagerly treated as defects: detector noise, film scratches, stamp marks, exposure digits, quirks of one machine, digitization traces. That is why you need a hard-negative set: frames where the model shouted “defect” and the expert said “no.” Without them an industrial detector drowns in false alarms and loses the shift’s trust.

The dataset matters more than the GPU: labels and active learning

A useful example is a radiograph plus acquisition and object metadata plus an expert report plus defect labels. Without metadata you cannot tell domain shift from a weak model. Carry at least: pipe diameter, wall thickness, material, welding process, joint type, radiography method, equipment, detector or film, exposure, projection, date, operator. Those fields explain why a network trained in one shop fails in another: different film, different kilovolts, different joint.

Treat the dataset as a product — owner, manifest, train/eval split — the same way as in dataset engineering. The domain is different; the rule is not: example contract first, volume and architecture second.

Do not pay for the most expensive labels on every frame. Four levels answer different questions at different cost.

Level What you label Why Rough share
1 whole frame → normal / defect filter, pilot, cheap volume all images
2 defect type on the frame class vocabulary, coarse stats part of the archive
3 box: x, y, w, h + class detector training thousands, not tens of thousands
4 pixel mask measurements and geometry even fewer: the valuable and disputed

An example split, not a standard: 50,000 frames with a binary tag, 15,000 with a class, 5,000 with a box or mask. Spend geometry labels on frames that change the model’s decision, not on the whole archive “just in case.”

You cannot and should not label everything by hand. The active-learning loop is: a thousand labeled frames → train → the model scores the unlabeled archive → the expert sees uncertain examples → labels → retrain. Frames at 0.99 “normal” and 0.98 “porosity” teach almost nothing. Frames at 0.51 / 0.48 on a class boundary are where expert time buys the most information.

Hard negatives are their own queue, not “another batch.” The model said “defect,” the expert rejected it. That frame goes into an explicit false-alarm set and back into training. In industrial radiography this is critical: stamps and scratches repeat more often than rare cracks, and without hard negatives the network optimizes “looks like a blob.”

Keep the evaluation gold set separate from the training archive — the same logic as a golden set for RAG: measure behavior, do not fit it with the file you trained on.

GDXray Welds: a lab set, not a plant loop

GDXray (and the later GDXray+ collection) is a public X-ray image database for NDT and computer vision, assembled by the GRIMA group. In the 2015 paper, Mery and co-authors describe the groups Castings, Welds, Baggage, Nature, and Settings. The welds group contains 88 images in three series; the radiographs were provided by BAM in Berlin. Say this out loud, because slide decks often treat “an open weld dataset” as “ready for production.”

Series W0001 is 10 images selected from a wider series, with defect annotations (the paper reports bounding boxes and ground truth for hundreds of discontinuities). W0002 is binary ideal masks for those same 10 frames. W0003 is a collection of digitized radiographs from a BAM round-robin on weld-flaw recognition: about 68 files, originally 12-bit, then linearly scaled to 8-bit. Exposure follows ISO 17636-1 class A; digitization follows ISO 14096-2. The limitation is already visible: you are not looking at the raw 16-bit stream of your detector, but at historically compressed teaching material.

Why 88 images ≠ 88 independent plant cases. W0001 is a subset of W0003, so correlation across series is built in. The volume is small for a stable small-object detector. Equipment, materials, and exposures do not cover your shop. The data predate typical modern digital panels. The collection is aimed at research and education; commercial redistribution is usually prohibited — check the current dataset page before embedding it in a product.

An honest use path:

GDXray Welds
  → proof of concept and loader tests
  → architecture baseline
  → tiling and detector experiments
  → pretraining / transfer if it helps
  → your plant images as the real sample

The public set answers “does the pipeline run.” “Can we put this on the floor” is answered only by an independent sample from your plant, on your equipment, with your defect vocabulary and your expert.

Who does what: CNN, YOLO, segmentation, CRNN, ViT

A convolutional net still fits because a defect on a radiograph is local texture, edge, shape, contrast against neighbors. Parameter counts stay relatively modest, and the inductive bias matches the physics of a spot on a weld. ResNet-50 is about 25 million parameters, DenseNet-121 about 8 million; EfficientNet and a light MobileNet span server-class down to smaller hardware. Training from scratch on a couple of thousand industrial frames is usually worse than taking an ImageNet-pretrained encoder and fine-tuning the upper layers on welds: low-level edge filters transfer; high-level “cats and dogs” do not, and those are what you replace.

YOLO (“You Only Look Once”) produces class, box, and confidence in one pass. That matches weld reality: several discontinuities, you need coordinates, box labeling is still tractable, inference is fast. Small objects remain hard: without tiling and without multi-scale heads the detector treats the weld as a landscape. A practical loop: large frame → 1024 × 1024 tile → YOLO → stitch. RT-DETR and other transformer detectors are alternatives; compare them on the same tiling and the same independent test, not on an abstract internet table.

Turn on segmentation when the business asks “how many millimetres” and “what area,” not only “there is a red square.” U-Net is at home on medical and industrial masks; heavier mask models help if you need detection and mask together. Measuring geometry from a box is self-deception for a long crack and for a chain of pores.

A hybrid worth treating as an experimental loop, not dogma:

flowchart TB
  xray[DICOM_or_TIFF]
  xray --> pre[Preprocess]
  pre --> weld[WeldROI]
  weld --> tile[Tiling]
  tile --> yolo[YOLO]
  tile --> cnn[CNN_features]
  yolo --> fuse[Fusion]
  cnn --> crnn[CRNN_along_weld]
  crnn --> fuse
  fuse --> seg[OptionalSegmentation]
  seg --> meas[Measurements]
  meas --> rules[RuleEngine]
  rules --> ui[ExpertUI]
  ui --> al[ActiveLearning]
  al --> ds[Dataset]

The upside: the detector proposes candidates, convolution and a sequence along the weld add context, rules are not baked into weights. The downside: more moving parts, more ways to leak data quietly, harder debugging. The hybrid is justified after a plain tiled YOLO is measured and its blind spots are known.

A separate network per defect type (one CNN only for pores, another only for cracks) looks tidy on a slide and scales poorly: shared preprocessing, shared weld, shared class confusion, multiplied deploys. One head with several classes is the default. A specialist model is justified later if one rare class (a crack, say) systematically loses in the shared head and you have a dedicated hard-example set. That exception is proven with metrics, not taste.

The link to existing CNN/CRNN skill is this: the encoder habit and sequence tooling transfer; the problem statement does not. In OCR the time axis is character order. On a weld the axis is joint geometry. You cannot drop UT-form weights onto a radiograph; you can drop the engineering habit (geometry and tiling first, then the model, then the human). That is the same lesson as in the UT form field notes.

System loop: detection, rules, expert

The machine-learning pipeline ends at candidates, not at a stamp in the NDT log.

DICOM/TIFF → preprocess → weld region → tiles
  → detection → classification → (segmentation) → measurements
  → rules engine → expert UI → feedback into the dataset

The rules layer takes type, size, location, sometimes count per unit length — and compares them with the inspection map. Its output is an engineering draft: “porosity, chain length X, versus threshold Y — for review.” Not “pass.” Disagreement of the form “the model sees a defect, the rule says it is allowed” must be visible, not hidden inside a single confidence number.

The expert interface is part of the product, not “an admin screen later.” On the image: a box or contour, type, size, confidence. Actions: accept, reject, correct class or geometry. Each action is a labeled example for the next cycle. Without that there is no active learning, only a one-off “we labeled in CVAT and forgot.”

A specialized web UI is justified because generic labeling tools are weak on radiographs: 16-bit, deep zoom, controlled contrast, an NDT defect vocabulary, confirmation of model proposals. The stack can be boring and sufficient: a React client, an API, a Python inference service, dataset versions in object storage. Eventually one loop is the labeling tool, the inspector workstation, and the active-learning queue. Until the pilot has proven the class vocabulary and detector quality, CVAT or Label Studio is enough — a custom UI must not become a way to postpone training.

A link to equipment risk is a later conversation, not a v1 feature. A defect candidate may later feed a risk-based inspection (RBI) module, but only after the discontinuity has type, size, location, and human confirmation. Otherwise a false alarm rides into the risk loop. The integrity-program logic is in the RBI field notes; the “radiograph → risk” bridge belongs in later articles of this line, not in the first work package.

Metrics, leakage, and domain shift

Accuracy on an imbalanced archive (“most welds are acceptable”) is a dangerous metric: a model that always says “normal” looks strong and is useless. Watch precision, recall, F1, ROC-AUC and PR-AUC, mAP for detection, IoU and Dice for masks, and false-positive / false-negative rates separately. For industrial inspection, recall on critical classes (crack, lack of penetration) matters more than a pretty average. A false alarm costs inspector time. A missed defect costs the meaning of the whole loop.

The most treacherous experimental bug is leakage through tiles.

Wrong: one radiograph is cut into 20 tiles, 15 go to train, 5 to test. Neighboring tiles are almost the same: film texture, exposure, weld geometry. The model “recognizes” the image, not the defect. Right: first split by object, weld, inspection, batch, or plant, then tile. If plant A is in training, the test set should be plant B, or at least another batch and another machine — otherwise you measure memorization of the setup, not generalization.

Domain shift is not abstract here. A network happily learns a specific machine, film, detector, the operator’s stamp habit, a typical exposure. The ideal experiment is harsh: train on plant A and equipment A, test on plant B and equipment B. If you have no second plant, at least keep a fully untouched hold-out by time and by shift.

Synthetic defects (“ideal weld + painted pores”) are fine for pretraining and for checking that the pipeline does not crash. They are not real discontinuities: scatter physics, edges, overlay on the weld root differ. The risk is learning an unrealistic artifact and shipping a pretty synthetic pilot. An honest path: synthetic → pretrain → fine-tune on real radiographs → evaluate only on real independent frames.

Labor, stack, and the first experiment

The figures below are an engineering estimate, not a budget norm and not a calendar promise. They exist so you do not plan “train YOLO over a weekend” and so you remember who actually spends the time: the expert.

Dataset stage Image count (order) Person-hours (order) Goal
Proof of concept 1,000–2,000 100–300 does the pipeline live, what is the baseline
Working prototype 5,000–10,000 400–1,000 a stable detector, a confusion matrix
Production-oriented 20,000–50,000+ 1,500–3,000+ independent test, rare classes

Pipeline development is tens of hours (roughly 40–100). The first training baseline is another few tens (30–80). Hyperparameter search 30–100. Error analysis 50–150 and usually more than you want. Labeling iterations eat most of the calendar. GPU time is relatively cheap. Inspector time is not.

A stack that is enough to avoid inventing a platform in month one: Python, PyTorch, OpenCV, Albumentations, NumPy, pandas; a YOLO detector (RT-DETR as a separate run); U-Net segmentation; run tracking in MLflow or similar; labeling in CVAT / Label Studio until you own a UI; DICOM/TIFF sources in object storage with dataset versions. This is not “the only correct list”; it is a way not to start by training a ViT and writing a labeler in the same sprint.

A practical first experiment fits in four phases.

Phase 1, one to two weeks. Collect 500–1,000 frames. Freeze the class vocabulary. Describe the annotation format. Build preprocessing that does not throw away bit depth. Train a baseline CNN classifier on tiles or on the weld region. The goal is not shop-floor accuracy; it is “signal exists / signal does not.”

Phase 2, one to two weeks. Boxes. YOLO on overlapping tiles. Confusion matrix. Review of false alarms and misses. The hard-negative set starts here, not “later.”

Phase 3. Compare: detector versus CNN+CRNN along the weld; segmentation on the subset where size matters; ViT only if volume and an independent test already allow a fair comparison.

Phase 4. Active learning, dataset growth, a fully independent test (another batch / another machine). Only then talk about the rules layer and the expert workstation as a product, not a demo.

Common mistakes

Mixing detection and accept/reject. The network emits “pass” because it is easier to paste into the report. Then the code changes — and you retrain what should have been a threshold table.

Resizing the whole frame to an ImageNet input. Small defects vanish. Metrics on large pores look fine; the crack is gone.

Tiling before splitting. Neighbors of one radiograph sit in train and test. The pilot “wins”; the plant image does not.

Training only on GDXray and showing that to a customer as readiness. Ten ideal masks and a BAM round-robin do not replace your detector, your film, and your expert.

One model per class from day one. Four deploys, four preprocesses, the same pore/slag confusion in four copies.

Optimizing accuracy. On an archive of acceptable welds it is high for the constant “everything is fine.”

Throwing false alarms away as trash. They are teaching material about stamps and scratches. Without them the expert switches the system off on the second shift.

Porting a CRNN from OCR without changing the axis. A character sequence is not a sequence of weld strips. Reuse the encoder idea, not the checkpoint.

What to try today

If you already have a radiograph archive, do not start by choosing “YOLO or ViT.” Do four things you will not throw away tomorrow.

Write the contract: what counts as a defect in your vocabulary, and what the model is not allowed to decide (acceptability). Put that next to the inspection map, not in a notebook.

Collect 200–500 frames with a binary tag and metadata for machine, thickness, and welding process. Even without boxes this is already a classification pilot and a check that sources read as DICOM/TIFF, not as an exported JPEG.

Split by weld or inspection before any tiling. Keep a folder the model must not see until the final report.

Run one stupid baseline: weld region → tiles → a small CNN. Save the list of its most confident mistakes — that is a draft hard-negative set and the agenda for a talk with the inspector.

FAQ

Can we put AI on the radiographic line right away?

No, not as the sole author of the report. First a pilot on the archive, an independent test, a rules layer, and mandatory human confirmation. Otherwise you automate a signature, not inspection.

How many images until it “already works”?

It depends on the defect vocabulary and equipment diversity. Order of magnitude: thousands for a pilot, tens of thousands for a stable detector, with expensive geometry labels only on a subset. A precise number without your archive is guesswork; the table above is a labor estimate, not a quality guarantee.

Why is YOLO better than a CNN on the whole frame?

A classifier does not say where the defect is or how many there are. A detector gives boxes and classes on one weld. If you only need “obviously clean / look with eyes,” a classifier can be a first filter.

Why segmentation if we already have boxes?

A box measures a long crack and porosity area poorly. A mask is needed when the code talks about size and shape, not “somewhere in this square.”

Should we start with a ViT?

On a typical plant volume in the first months — no. Convolution and a pretrained detector first, then a transformer comparison on the same independent test. Otherwise you compare undertrained models, not inductive biases.

Why not cut the image and randomly sprinkle tiles into train and test?

Neighboring fragments of one radiograph are near-duplicates. The model memorizes the image, not the defect. Split objects of inspection; tile only inside a split.

Can a rules layer replace the inspector?

No. Rules encode code thresholds. The expert closes doubtful cases, artifacts, conflicting projections, and the responsibility of the report. Model and rules narrow the work to the disputed; they do not cancel it.

Further reading

Sibling pieces on this site cover the same discipline in other domains — no need to retell them here.

How CNN and CRNN work on a sequence — handwritten digits: from CNN to TrOCR. How an industrial pilot keeps a human in the loop — the UT form and why one model is not enough. How not to mix training and evaluation — dataset engineering and a golden set for RAG. Why to count the cost of a miss, not only the comfort of automation — testing economics. Where a confirmed defect can go next — risk-based inspection.

Later articles in this line should take one axis each: a first experiment on GDXray Welds, training YOLO on weld defects, CNN+CRNN along the weld, active learning with the inspector, segmentation versus boxes for measurement, ViT versus CNN, building a plant dataset, and the bridge to RBI.

Conclusion

Automatic analysis of weld radiographs is not “download a huge model.” It is a loop: high-bit source, weld region, tiles, a reasonably sized detector and classifier, a mask and measurements when needed, separately the acceptance rules, separately the human, separately the labeling cycle. A multi-million-parameter CNN and tiled YOLO already make a serious pilot. CRNN is a hypothesis for elongated context. ViT is an alternative encoder on a large set, not the start. Public GDXray Welds checks the code, not shop-floor readiness.

A practical step this week: take a batch of real frames, forbid JPEG as the only store, split by weld, and train the simplest tile classifier. The list of its confident mistakes will tell you more about your archive than an architecture table. In the lab of code that looks like assembling a loop with joints you can inspect, not like buying “AI for NDT” in a single contract.