You need to agree to share your Hugging Face information to access this model
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
Access to the weights in thinking-friends/weld-defect-retinanet is gated.
These weights are released by Thinking Friends under the thinkingfriends-nc
license for non-commercial and educational use only. Commercial use requires
a separate license from Thinking Friends (help@thinkingfriends.co.kr).
This repository distributes model weights only. It does not include the
original training images or annotations. Training used the AI Hub dataset
「창원 지역 특화산업 고도화 및 디지털 전환 촉진을 위한 용접 AI 학습 데이터 구축」
(dataSetSn=71761; https://www.aihub.or.kr). Redistribution of the original
AI Hub data is not allowed.
By requesting access you confirm that you have read LICENSE, that you will
use the weights only for non-commercial or educational purposes unless you
obtain a commercial license, and that you will not redistribute the original
training data.
Log in or Sign Up to review the conditions and access this model content.
TFVision Weld Inspection Detector (weld_v5)
A weld appearance inspection detector from Thinking Friends (띵킹프렌즈). It predicts bounding boxes for weld beads and defect types, and it also makes an image-level GOOD/BAD decision.
Repository: thinking-friends/weld-defect-retinanet
Access is gated. Request access with the form on the model page (name, affiliation, intended use, and a non-commercial agreement). A Korean model card is in README_ko.md.
The training datasets are not released and are not included in this repository.
License
thinkingfriends-nc (license: other). Use is limited to non-commercial and educational purposes. Commercial use requires a license from Thinking Friends.
Commercial licensing contact: help@thinkingfriends.co.kr
Company websites: thinkingfriends.co.kr, tftas.com
This license does not override upstream terms of the training data or the base model. AI Hub’s official FAQ states that AI models, services, and other derivative works trained on the data may be used, sold, or distributed for commercial or non-commercial purposes, with attribution (the official dataset name and aihub.or.kr). Limiting this repository to non-commercial use is a choice by Thinking Friends. Redistribution of the original data is not allowed. See LICENSE. Official texts do not say whether placing weights on an overseas server counts as “export abroad” under the AI Hub usage policy.
Model summary
| Item | Detail |
|---|---|
| Architecture | torchvision RetinaNet, ResNet-50 FPN v2 |
| Base weights | RetinaNet_ResNet50_FPN_V2_Weights.COCO_V1 (COCO pre-training). Code is BSD-3-Clause. This is not a Hyundai Motor / HMG checkpoint. |
| Task | 10-class object detection plus image-level GOOD/BAD |
| Input | RGB still images, long side 1,024 px at training and inference time (pad_square false) |
| Image-level rule | An image is BAD if any non-good box scores at least confidence 0.25 |
| Released file | Seed 43 best_weights.pt (same bytes as weld_retinanet_r50fpnv2_s43.pt) and weld_retinanet_r50fpnv2_s43.safetensors (state_dict only). The close-up / mid-range entrance neural gate and the close-up image classifier have not been formally trained or packaged for this release. |
Classes: good, bad, defect_unspecified, porosity, deposit, discontinuity, stain, incomplete_penetration, lack_of_fusion, undercut.
Torchvision labels are 0 = background and 1..10 in the order above. See config.json.
What is (and is not) in this repository
- Included when published:
best_weights.pt(a checkpoint dict with amodelstate_dict), this card, LICENSE, config.json, and inference.py. - Not included: AI Hub, Kaggle, or LoHi-WELD images or annotations; watermarked or stock example photos; optimizer states needed only for resuming training.
System logic: close-up vs mid-range
Failure modes differ by shooting distance. AI Hub images are mostly mid-range; Kaggle and LoHi include many close-up crops of the weld. The intended inference path is to classify distance at the entrance, then use a different branch.
Available now
- Mid-range branch. The weld_v5 detector in this card. On the AI Hub test set the three-seed mean mAP50 is 0.841 and the error rate is about 1%.
- LoHi entrance. A resolution rule only: if the short side is at least 110 px the image is treated as a high-resolution crop, otherwise as low-resolution. Accuracy was 1.000 on the 2,694-image LoHi hold-out.
- AI Hub entrance. Treated as mid-range by a resolution rule. On a 2,000-image sample, one image was mis-routed (accuracy 0.9995, error rate 0.0005). An extra cap such as max side below 900 px can reduce the case where a long, thin mid-range frame is mistaken for a high-resolution crop.
- LoHi high-resolution (close-up crop) image-level decisions. Use this detector for now. Seeds 43 and 44 had BAD recall 1.000 on the 950 high-resolution images. LoHi has no GOOD images, so false-alarm rate is not measured.
Planned, not in this release
- Kaggle-style image gate. All Kaggle frames are 640×640, so a resolution rule cannot separate close-up from mid-range (accuracy 0.498, AUROC 0.500 with the rule alone). A CPU proof-of-concept ResNet18 + logistic trained only on the Kaggle 200-image set reached AUROC 0.802 and accuracy 0.726 on the 1,513-image hold-out. Mixing all three sources dropped AUROC to 0.677, so the gate should stay Kaggle-specific. These gate weights are not a formal fine-tune and are not part of the release.
- Kaggle close-up image classifier. The close-up branch is planned as an image-level GOOD/BAD classifier rather than a second detector. In a zero-CU check, a ResNet50 + logistic evaluated with group-preserving 5-fold OOF on the same 759 Kaggle close-up images reached AUROC 0.900, F1 0.882, and error rate 0.159, ahead of the stage-3 detector seed 44 (AUROC 0.855, F1 0.835, error rate 0.209). A short Colab L4 fine-tune was waiting on compute and is not included in this release.
- For Kaggle images where the gate is uncertain, the plan is to combine detector and classifier scores rather than hard-switch.
Training data size
The datasets themselves are not released. Counts below are the images used to train the final detector (weld_v5 stage 3).
| Split | Images | Composition |
|---|---|---|
| Train | 12,377 | AI Hub 11,977 + Kaggle 200 + LoHi 200 |
| Validation | 3,137 | AI Hub |
| Test | 6,294 | AI Hub |
| Held-out evaluation | 4,207 | Kaggle 1,513 + LoHi 2,694 |
All three seeds used the same splits. These counts are not the raw upstream corpus sizes (for example the full AI Hub VT set).
Fine-tuning scale
Only the scale of the final detector is listed, not the development process.
- Start from COCO-pretrained RetinaNet-R50-FPN-v2; adapt to 10 weld classes
- 8 epochs, 12,377 training images, batch 16, 1,024 px input, seeds 42, 43, and 44
- About 2.62–2.65 hours of Colab NVIDIA L4 runtime per seed; 7.906 hours for three seeds (logged). Estimated compute (runtime hours × 1.94, estimate) about 15.34 CU
- The published file is seed 43 (highest AI Hub test mAP50 and Kaggle held-out mAP50 among the three seeds)
Training compute
Summary of the main GPU runs that led to the final model. CU values, some GPU labels, and calendar time around disconnects are estimates. The A5000 was not used.
| Stage | Run | GPU | Hours | Hours basis | Est. CU | CU basis |
|---|---|---|---|---|---|---|
| v1 full | Kaggle+LoHi, 15 epochs, 2,809 images | A100-SXM4-80GB | 0.347 | logged wall 1,248.04 s | 3.6 | report memo (estimate) |
| v2 full | AI Hub VT, 15 epochs, 30,299 images | A100 then L4 mixed (inferred from throughput) | 4.710 | sum of epoch times (training only) | 25.9 | report memo 109.7→83.8 (estimate). Calendar span including disconnects ≈ 9.3 h (estimate) |
| v3 full | Joint three-source, 15 epochs, 39,674 images | L4 | 5.526 | sum of epoch times (training only) | 10.72 | hours × 1.94 (estimate) |
| v3 LOSO ×2 | 8 epochs each | L4 | 1.965 + 2.493 | sum of epoch times | 3.81 + 4.84 | hours × 1.94 (estimate) |
| v4 stage-1 LOSO ×2 | 8 epochs each | L4 | 2.400 + 2.839 | runtime hours | 4.66 + 5.51 | runtime × 1.94 (estimate) |
| v4 stage-2 smoke + 4 fine-tunes | 1+4 epochs | L4 | 0.146 + 1.564 | runtime hours | 0.28 + 3.03 | runtime × 1.94 (estimate) |
| v5 stage 3, 3 seeds | 8 epochs each, 12,377 images | L4 | 7.906 | official runtime total | 15.34 | runtime × 1.94 (estimate) |
Logged training time by GPU (the v2 split is an estimate and must not be added on top of the parent 4.710 h row):
- NVIDIA A100: v1 0.347 h + v2 epochs 1–10 estimated 2.077 h ≈ 2.424 h (v2 segment estimated)
- NVIDIA L4: v2 epochs 11–15 estimated 2.633 h + v3 epoch sum 9.984 h + v4 runtime 6.949 h + v5 runtime 7.906 h ≈ 27.472 h (v2 segment estimated)
- If v2 is counted only as one mixed block, the logged training-time total is 0.347 + 4.710 + 9.984 + 6.949 + 7.906 = 29.896 h.
Results (confidence 0.25)
Binary metrics use the non-good box-score threshold 0.25. The LoHi hold-out has no GOOD images (75 EMPTY images are excluded). Figures are the official three-seed means unless a two-seed mean is labelled as such.
Official three-seed mean
| Set | n | mAP50 | Precision | Recall (BAD) | F1 | GOOD recall | AUROC |
|---|---|---|---|---|---|---|---|
| AI Hub test | 6,294 | 0.841 | 0.9941 | 0.9873 | 0.9907 | 0.993 | 0.9993 |
| Kaggle hold-out | 1,513 | 0.2928 | 0.8357 | 0.7765 | 0.8048 | 0.7318 | 0.8276 |
| LoHi hold-out | 2,694 | 0.3958 | 1.0 | 0.9878 | 0.9938 | — | — |
Ranges (min–max): AI Hub test mAP50 0.835238–0.84534; Kaggle mAP50 0.281335–0.299915; LoHi mAP50 0.386735–0.402871. AI Hub GOOD recall was 0.993026 on all three seeds.
Close-up / mid-range (seeds 43 and 44; seed 42 has no prediction files)
Kaggle “practical close-up” means a ground-truth box area ratio ≥ 0.10 or a max-side ratio ≥ 0.70. LoHi is split by resolution (high/low). AI Hub is mid-range by source. Two-seed means are arithmetic averages of the file values (computed).
| Slice | n | Model | GOOD recall | BAD recall | Error rate | mAP50 |
|---|---|---|---|---|---|---|
| Kaggle practical close-up | 759 | s43 | 0.7652 | 0.7832 | 0.2227 | 0.2768 |
| Kaggle practical close-up | 759 | s44 | 0.7976 | 0.7871 | 0.2095 | 0.2703 |
| Kaggle practical close-up | 759 | s43·s44 mean | 0.7814 | 0.78515 | 0.2161 | 0.27355 |
| Kaggle practical mid-range | 754 | s43 | 0.7076 | 0.8035 | 0.2347 | 0.3207 |
| Kaggle practical mid-range | 754 | s44 | 0.6977 | 0.8256 | 0.2255 | 0.3253 |
| Kaggle practical mid-range | 754 | s43·s44 mean | 0.70265 | 0.81455 | 0.2301 | 0.3230 |
| LoHi high-res (close-up crop) | 950 | s43 | — | 1.0 | 0.0 | 0.3878 |
| LoHi high-res (close-up crop) | 950 | s44 | — | 1.0 | 0.0 | 0.3866 |
| LoHi high-res (close-up crop) | 950 | s43·s44 mean | — | 1.0 | 0.0 | 0.3872 |
| LoHi low-res | 1,744 | s43 | — | 0.9802 | 0.0198 | 0.4071 |
| LoHi low-res | 1,744 | s44 | — | 0.9892 | 0.0108 | 0.4048 |
| LoHi low-res | 1,744 | s43·s44 mean | — | 0.9847 | 0.0153 | 0.40595 |
| AI Hub test (mid-range) | 6,294 | s43 | 0.993 | 0.9857 | 0.011 | 0.8441 |
| AI Hub test (mid-range) | 6,294 | s44 | 0.993 | 0.9883 | 0.0095 | 0.8343 |
| AI Hub test (mid-range) | 6,294 | s43·s44 mean | 0.993 | 0.9870 | 0.01025 | 0.8392 |
The official three-seed AI Hub test mAP50 is 0.841 (not the two-seed mean in the table above).
Per-class AP50, three-seed mean: Kaggle good 0.4086, bad 0.3876, defect_unspecified 0.0821. LoHi porosity 0.2902, deposit 0.2841, discontinuity 0.6269, stain 0.3819. AI Hub good 0.9866, porosity 0.6389, incomplete_penetration 0.9486, lack_of_fusion 0.859, undercut 0.7721.
Examples
The figure below shows seed-43 predictions (confidence ≥ 0.25) on four held-out images. Solid boxes are model predictions (class name and score). Dashed boxes are ground truth. The image-level label is BAD if any non-good box scores at least 0.25, otherwise GOOD.
These are selected examples, not a random sample. Average performance is in the tables above.
Top row: two LoHi-WELD close-up BAD cases. Bottom row: one Kaggle close-up GOOD weld, and one Kaggle mid-range BAD scene. In the mid-range example the upper coupon is labeled good; the lower coupon has overlapping bad and defect_unspecified boxes in both the prediction and the ground truth.
Sources of the photographs:
- LoHi-WELD high-resolution welds (close-up crops). Please cite: S. B. Block, R. D. da Silva, A. E. Lazzaretti, and R. Minetto, “LoHi-WELD: A Novel Industrial Dataset for Weld Defect Detection and Classification, a Deep Learning Study, and Future Perspectives,” IEEE Access, 2024. https://doi.org/10.1109/ACCESS.2024.3407019
- Sukma Adhi Wijaya, Welding Defect - Object Detection (Kaggle). Watermarked or stock-looking Kaggle frames were not used. AI Hub images are not shown.
Individual annotated frames are in thinking-friends/weld-defect-examples.
How to use
After you are granted access, download best_weights.pt and the files in this repository. Do not point the script at original AI Hub images for redistribution; use your own image.
Path check only (no model load):
python inference.py --config config.json --weights best_weights.pt
One image on CPU:
python inference.py --config config.json --weights best_weights.pt --image /path/to/weld.jpg --device cpu
Equivalent Python (eval pre-processing matches training: long side 1,024 px, per-image mean/std remapped to ImageNet statistics, score threshold 0.25):
import json
from pathlib import Path
import torch
from PIL import Image
from torchvision.models.detection import retinanet_resnet50_fpn_v2
from torchvision.transforms.functional import to_tensor
cfg = json.loads(Path("config.json").read_text())
classes = cfg["classes"]
imgsz, conf = cfg["imgsz"], cfg["conf"]
ckpt = torch.load("best_weights.pt", map_location="cpu", weights_only=False)
model = retinanet_resnet50_fpn_v2(
weights=None, weights_backbone=None,
num_classes=cfg["num_det_classes"], min_size=imgsz, max_size=imgsz,
)
model.load_state_dict(ckpt["model"])
model.eval()
img = Image.open("/path/to/weld.jpg").convert("RGB")
w, h = img.size
scale = imgsz / max(w, h)
if scale != 1.0:
img = img.resize((round(w * scale), round(h * scale)), Image.Resampling.BILINEAR)
x = to_tensor(img)
mean, std = x.reshape(3, -1).mean(1), x.reshape(3, -1).std(1, unbiased=False).clamp_min(1e-6)
im_mean = x.new_tensor(cfg["imagenet_mean"]).view(3, 1, 1)
im_std = x.new_tensor(cfg["imagenet_std"]).view(3, 1, 1)
x = (x - mean.view(3, 1, 1)) / std.view(3, 1, 1) * im_std + im_mean
with torch.inference_mode():
out = model([x])[0]
keep = out["scores"] >= conf
for box, score, lab in zip(out["boxes"][keep] / scale, out["scores"][keep], out["labels"][keep]):
name = classes[int(lab) - 1]
print(name, float(score), box.tolist())
Requires PyTorch and torchvision. The script defaults to CPU.
Limitations
- Licensing: most training images come from AI Hub 71761. The FAQ allows commercial use, sale, and distribution of models trained on the data, and requires credit (the official dataset name and aihub.or.kr). The original data must not be redistributed. Official texts do not say whether placing weights on an overseas server counts as “export abroad.” This repository is gated and limited to non-commercial use by Thinking Friends.
- The LoHi evaluation set has no GOOD images, so high BAD recall does not mean a low false-alarm rate.
- Kaggle box mAP50 is weaker than image-level scores. The unspecified-defect class is especially weak (AP50 0.0821).
- The close-up classifier and the Kaggle image gate are not formally trained. The published weights are the detector only.
- The Kaggle compilation may contain stock or watermarked images. Example photos on this card were visually screened; watermarked or stock-looking Kaggle images were not used. AI Hub images are not shown.
- Reported scores are on public / lab splits, not a guarantee on a customer’s cameras or process.
Attribution
Training used:
- The AI Hub dataset 「창원 지역 특화산업 고도화 및 디지털 전환 촉진을 위한 용접 AI 학습 데이터 구축」 (dataSetSn=71761), a project of the Ministry of Science and ICT and the National Information Society Agency (NIA). Rights in the dataset remain with the performing institutions (including Gyeongnam Technopark) and NIA. The original data is not redistributed with this model. Dataset page · AI Hub
- S. B. Block, R. D. da Silva, A. E. Lazzaretti, and R. Minetto, “LoHi-WELD: A Novel Industrial Dataset for Weld Defect Detection and Classification, a Deep Learning Study, and Future Perspectives,” IEEE Access, 2024. https://doi.org/10.1109/ACCESS.2024.3407019
- Sukma Adhi Wijaya, Welding Defect - Object Detection (Kaggle; compilation declared CC0).
- torchvision RetinaNet (BSD-3-Clause), initialized from COCO pre-trained weights.
Disclaimer
This card and the accompanying LICENSE are not legal advice. The model is provided “as is.” See LICENSE for the full warranty disclaimer.
- Downloads last month
- -
