Industrial computer vision workflow for welding surface inspection using Ultralytics YOLO, OpenCV preprocessing, dataset QA, threshold governance, and edge-readiness planning.
This repository is a portfolio showcase for manufacturing AI, machine vision, and production-oriented ML engineering. It demonstrates how a weld-defect detection notebook can be structured for engineering review, not just model training.
| File | Purpose |
|---|---|
Welding_Defect_YOLO_Industrial_Workflow.ipynb |
Executable notebook covering dataset QA, EDA, preprocessing, YOLO training controls, inference policy, export planning, drift strategy, and test gates. |
Welding_Defect_YOLO_Industrial_Workflow.pdf |
Presentation/export version of the notebook for quick review. |
MODEL_CARD.md |
Workflow and model-card style summary for intended use, non-use, validation gaps, and release gates. |
DATASET_PROVENANCE.md |
Dataset source, expected structure, audit notes, and production data-governance caveats. |
RELEASE_CHECKLIST.md |
Practical checklist for moving from notebook workflow to production pilot. |
requirements.txt |
Core Python dependencies for notebook execution. |
requirements-export.txt |
Optional dependencies for model export and ONNX Runtime checks. |
environment.yml |
Conda-compatible environment specification. |
CITATION.cff |
Citation metadata for academic or portfolio reference. |
- Dataset discovery and runtime-safe
data.yamlnormalization across local, Kaggle, and notebook environments. - YOLO-format label parsing with hard checks for invalid labels, unreadable images, missing labels, orphan labels, duplicate boxes, tiny objects, and cross-split leakage.
- Manufacturing-focused EDA for class balance, object density, box scale, center bias, and visual label review.
- Deterministic OpenCV preprocessing with CLAHE, grayscale conversion, edge diagnostics, morphology views, and station-style image-quality metrics.
- Guarded YOLO run modes for
audit,smoke_train,full_train, andexport. - False-positive and false-negative review scaffolding through confidence threshold sweeps when a trained model is supplied.
- Fail-safe station inference wrapper that routes missing-model or inference-failure cases to manual review instead of pass.
- Extension paths for oriented bounding boxes, segmentation, ResNet crop classification, edge export, drift monitoring, retraining triggers, and release governance.
The checked-in notebook was executed in audit mode. That means the data integrity and workflow checks were run, while long-running model training, export, and edge benchmarking were intentionally skipped.
Saved audit highlights:
| Metric | Value |
|---|---|
| Images indexed | 2,028 |
| YOLO label rows indexed | 5,686 |
| Invalid label rows | 0 |
| Unreadable images | 0 |
| Missing label files | 0 |
| Orphan label files | 0 |
| Duplicate boxes | 0 |
| Exact cross-split duplicate image groups | 4 |
| Border-touching boxes | 1,529 |
| Tiny boxes | 286 |
| Large boxes | 67 |
Important interpretation:
- No trained weld model weights are included in this repository.
- The saved run does not include validation metrics, threshold sweep results, exported artifacts, or target-hardware latency results.
- The public dataset is a proxy dataset for workflow demonstration. Production acceptance requires plant-specific imagery, quality-approved labels, and station validation.
Primary public dataset referenced by the notebook:
Kaggle Welding Defect - Object Detection
https://www.kaggle.com/datasets/sukmaadhiwijaya/welding-defect-object-detection
The dataset is not redistributed in this repository. See DATASET_PROVENANCE.md for setup and governance notes.
Create a Python environment:
python -m venv .venvWindows PowerShell:
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
jupyter labLinux/macOS:
source .venv/bin/activate
pip install -r requirements.txt
jupyter labFor export checks, install optional dependencies:
pip install -r requirements-export.txtThe notebook is controlled through environment variables.
| Mode | Purpose |
|---|---|
audit |
Dataset QA, EDA, preprocessing diagnostics, and static production handoff sections. |
smoke_train |
Short one-epoch YOLO training run for wiring validation. |
full_train |
Full configured training run. |
export |
Load a trained model and run export/edge checks. |
Example PowerShell run setup:
$env:WELD_RUN_MODE = "audit"
$env:WELD_DATASET_ROOT = "C:\path\to\welding-defect-object-detection"
jupyter labExample evaluation with an existing trained YOLO model:
$env:WELD_RUN_MODE = "audit"
$env:YOLO_MODEL_PATH = "C:\path\to\best.pt"
jupyter labTo convert this showcase into a production-pilot package:
- Replace the public proxy dataset with plant-specific, quality-approved imagery.
- Freeze the annotation guide and defect taxonomy.
- Remove duplicate leakage across train, validation, and test splits.
- Train a weld-specific YOLO model and preserve
best.pt,last.pt, metrics, plots, and run manifest. - Review false negatives for rejectable classes with quality engineering.
- Select thresholds using false-accept risk, not aggregate accuracy alone.
- Validate exported artifacts on target edge hardware.
- Run shadow-mode comparison against manual inspection and final quality disposition.
- Enable structured station logs for drift, overrides, latency, and retraining triggers.
Repository documentation and original workflow code are released under the MIT License. Dataset files, third-party packages, pretrained model weights, and external assets remain governed by their respective licenses.