Skip to content

Repository files navigation

Battery-Case Spot Weld Defect Detection with YOLO

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.

Repository Contents

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.

What This Project Demonstrates

  • Dataset discovery and runtime-safe data.yaml normalization 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, and export.
  • 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.

Saved Notebook Audit State

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.

Dataset

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.

Quick Start

Create a Python environment:

python -m venv .venv

Windows PowerShell:

.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
jupyter lab

Linux/macOS:

source .venv/bin/activate
pip install -r requirements.txt
jupyter lab

For export checks, install optional dependencies:

pip install -r requirements-export.txt

Run Modes

The 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 lab

Example evaluation with an existing trained YOLO model:

$env:WELD_RUN_MODE = "audit"
$env:YOLO_MODEL_PATH = "C:\path\to\best.pt"
jupyter lab

Production-Pilot Next Steps

To convert this showcase into a production-pilot package:

  1. Replace the public proxy dataset with plant-specific, quality-approved imagery.
  2. Freeze the annotation guide and defect taxonomy.
  3. Remove duplicate leakage across train, validation, and test splits.
  4. Train a weld-specific YOLO model and preserve best.pt, last.pt, metrics, plots, and run manifest.
  5. Review false negatives for rejectable classes with quality engineering.
  6. Select thresholds using false-accept risk, not aggregate accuracy alone.
  7. Validate exported artifacts on target edge hardware.
  8. Run shadow-mode comparison against manual inspection and final quality disposition.
  9. Enable structured station logs for drift, overrides, latency, and retraining triggers.

License

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.

About

Industrial computer vision workflow for welding defect inspection using YOLO, OpenCV preprocessing, dataset QA, threshold governance, and edge-readiness analysis.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages