A small convolutional autoencoder that flags defects in X-ray tiles of steel welds: porosity, cracks and lack of penetration. It was trained only on defect-free (sound) welds. A tile it cannot rebuild well is anomalous, and the error map shows where.
Made by Team 1 (Jerome, Kazuko, Amelia, Sahil) for the AI Methods I hackathon, IAAC Master in AI for Architecture & the Built Environment, November 2026. Code, notebook and figures: github.com/iaac-maai/hackathon-team1-weld-anomaly.
X-ray tile ─► greyscale, 64×64, 0–1 ─► ENCODER ─► 32 numbers ─► DECODER ─► rebuilt tile
│
score = mean((input − rebuilt)²) ◄──────────────────────┘
error map = (input − rebuilt)² per pixel
The decoder only learned to draw sound welds, so a defect is missing from the rebuilt tile and the error is high exactly there.
| Risk level | Score | Meaning |
|---|---|---|
| 🟢 low | ≤ 0.000255 | looks like a sound weld |
| 🟠 check | 0.000255 – 0.001442 | unusual, an inspector should look |
| 🔴 high | > 0.001442 | strongly abnormal, inspect first |
Intended use: a screening aid that ranks X-ray tiles so an inspector reviews the riskiest first. Not an accept/reject decision under welding standards.
| File | Contents |
|---|---|
anomaly_ae.onnx |
The model (architecture + weights), for ONNX Runtime. Input image (N, 1, 64, 64) float32 0–1 → output reconstruction, same shape |
anomaly_ae.pt |
PyTorch state_dict of the ConvAE class in the notebook (ConvAE(64, 32)) |
anomaly_ae_config.json |
Preprocessing, score definition, thresholds and results. The server must follow it exactly |
import json
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from PIL import Image
repo = "iaac-maai/hackathon-team1-weld-anomaly-ae"
session = ort.InferenceSession(hf_hub_download(repo, "anomaly_ae.onnx"))
config = json.load(open(hf_hub_download(repo, "anomaly_ae_config.json")))
size = config["image_size"] # 64
img = Image.open("weld_tile.png").convert("L").resize((size, size), Image.Resampling.BILINEAR)
x = (np.asarray(img, dtype=np.float32) / 255.0)[None, None] # (1, 1, 64, 64)
rebuilt = session.run(None, {"image": x})[0]
error_map = (rebuilt - x)[0, 0] ** 2 # where to look
score = float(error_map.mean())
level = "high" if score > config["t_high"] else "check" if score > config["t_low"] else "low"
print(f"score {score:.6f} -> {level}")
The input should be a radiograph tile like those in RIAWELC: greyscale, about 227 × 227 px, showing a section of a weld.
RIAWELC: 24,407 greyscale X-ray tiles (227 × 227 px) of steel welds from 29 radiographs, in four classes: no defect, porosity, crack, lack of penetration.
The images are not redistributed here. Please cite the dataset authors (below).
ConvAE. Encoder: 3 × (Conv 3×3 stride 2 + BatchNorm + ReLU), 64 → 8 px, then a linear layer to a 32-number code. The decoder mirrors it with transposed convolutions and a sigmoid. 718,369 parameters.| Validation (5 welds) | Test (4 unseen welds) | |
|---|---|---|
| ROC AUC (defect vs sound) | 0.990 | 0.999 |
| AUC porosity / crack / lack of penetration | 0.994 / 0.985 / 0.998 | 0.999 / 0.999 / 0.999 |
| Precision / recall at the 95% threshold | 0.981 / 0.958 | 0.994 / 0.984 |
| Contrast-only baseline, ROC AUC | 0.946 | 0.936 |
Risk levels on the test set:
The fair summary is about 0.99 ROC AUC on unseen welds: the test set has only 4 welds.
anomaly_ae.onnx 3 MBanomaly_ae.pt 3 MB