Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Weld Defect Vision

Live Demo

Industrial weld defect detection research sandbox using YOLOv8 fine-tuning. It demonstrates 5 defect labels: Crack, Porosity, Spatter, Undercut, and Overlap. The repository is a synthetic-data validation discovery surface, not evidence of plant-floor performance.

Technical review pack: docs/architecture-pack.md

System Overview

An industrial inspection AI workflow that sells value through validation discovery, data-suitability review, and operator-readable evidence.

Area Details
Users Manufacturing quality teams, welding inspection groups, industrial AI teams, and edge deployment quality reviewers.
System scope YOLOv8 workflow, synthetic scenarios, Triton/Jetson notes, MES/SCADA integration framing, model governance, and technical review pack.
Operating boundary Prototype outputs need human inspector review; production use, yield claims, and customer outcomes require site-specific validation and acceptance criteria.
Evaluation path Inspect the model card, validation notes, serving docs, and deterministic sample outputs.

Evaluation Path

  • Start here: Read the model card and validation notes before checking detections.
  • Local demo: Start the API with uvicorn api.main:app --host 0.0.0.0 --port 8000, then test /detect or /detect/visualize.
  • Checks: Run pytest -v; keep human inspector review explicit when presenting outputs.

Service Launch Playbook

  • Service launch playbook maps the repository to its product scope, operating gates, operating boundaries, and risk controls.

Architecture Notes

  • Architecture guide summarizes the system scope, first files to inspect, runtime commands, and known boundaries.
  • Quality notes lists the local checks, CI surface, and release expectations for this repository.
  • Enterprise readiness notes outlines security, data, operations, integration, and handoff expectations.

Architecture

Input Image (640x640)
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  YOLOv8 Backbone (CSPNet) β”‚  ← COCO pretrained weights
β”‚  + FPN Neck               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚ Multi-scale features
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Detection Head           β”‚
β”‚  3 scales: P3/P4/P5       β”‚
β”‚  Per anchor: bbox + cls   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
    NMS β†’ Detections
    [bbox, class, confidence]

Key Features

  • YOLOv8 Fine-tuning: Transfer learning from COCO-pretrained weights for weld defect domain
  • 5 Defect Classes: Crack, Porosity, Spatter, Undercut, Overlap
  • Data Augmentation: Mosaic, MixUp, HSV jitter, flip (built into YOLO pipeline)
  • Evaluation: mAP@50, mAP@50-95, per-class precision/recall charts
  • Visualization: Bounding box overlay with class-specific colors and confidence scores
  • Inference API: FastAPI endpoint for real-time detection + annotated image response
  • Docker: GPU-enabled training and CPU/GPU serving containers

Project Structure

weld-defect-vision/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py        # Hyperparameters, class labels, colors
β”‚   β”œβ”€β”€ dataset.py       # YOLO dataset prep, validation, synthetic data
β”‚   β”œβ”€β”€ train.py         # YOLOv8 training pipeline
β”‚   β”œβ”€β”€ evaluate.py      # mAP evaluation with per-class charts
β”‚   β”œβ”€β”€ inference.py     # Detection wrapper (single/batch)
β”‚   └── visualize.py     # Bounding box drawing, detection grid
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ main.py          # FastAPI detection server
β”‚   └── schemas.py       # Request/response models
β”œβ”€β”€ data/
β”‚   └── weld_defect.yaml # YOLO dataset configuration
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_dataset.py  # Dataset and label format tests
β”‚   β”œβ”€β”€ test_train.py    # Config and training component tests
β”‚   └── test_api.py      # API endpoint tests
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ pyproject.toml
└── requirements.txt

Quick Start

Setup

pip install -r requirements.txt

Prepare Dataset

# Option 1: Use real weld defect dataset (place in data/ with YOLO format)
# Recommended: https://www.kaggle.com/datasets (search "weld defect detection")

# Option 2: Generate synthetic data for pipeline testing
python -m src.dataset --synthetic 200

# Validate dataset structure
python -m src.dataset data/weld_defect.yaml

Expected YOLO format:

data/
β”œβ”€β”€ weld_defect.yaml
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ val/
β”‚   └── test/
└── labels/          # class x_center y_center width height (normalized)
    β”œβ”€β”€ train/
    β”œβ”€β”€ val/
    └── test/

Train

python -m src.train

Outputs:

  • checkpoints/best.pt β€” Best model weights
  • runs/detect/weld_defect/ β€” Training curves, PR curves, confusion matrix

Evaluate

python -m src.evaluate checkpoints/best.pt

Outputs:

  • outputs/evaluation_results.json β€” Full metrics (mAP, precision, recall per class)
  • outputs/per_class_metrics.png β€” Per-class AP/P/R bar chart

Inference API

uvicorn api.main:app --host 0.0.0.0 --port 8000

# Detect defects (JSON response)
curl -X POST http://localhost:8000/detect -F "file=@weld_image.jpg"

# Detect + visualize (annotated image response)
curl -X POST http://localhost:8000/detect/visualize -F "file=@weld_image.jpg" -o result.png

Docker

# Inference server
docker compose up api

# Training (GPU)
docker compose --profile training run train

Tests

pytest -v

Defect Classes

Class Description Color
Crack Linear discontinuity in weld metal Red
Porosity Gas pockets trapped during solidification Green
Spatter Metal droplets expelled during welding Blue
Undercut Groove melted into base metal at weld toe Orange
Overlap Weld metal flowing over base metal without fusion Purple

Tech Stack

Component Technology
Object Detection YOLOv8 (Ultralytics)
Deep Learning PyTorch
Image Processing OpenCV
Evaluation matplotlib, seaborn
API FastAPI, Uvicorn
Container Docker, Docker Compose (GPU support)
Testing pytest
Production Serving Triton Inference Server (via serving/)
Edge Runtime Jetson Orin + TensorRT (via edge/)
Industrial Integration OPC-UA, MQTT, Kafka, REST webhook

Fictional Deployment Scenarios

The files under docs/case-studies/ are architecture exercises, not customer case studies. The organizations, engagements, deployments, datasets, benchmarks, and outcomes are fictional; every numeric value is fabricated and unmeasured:

Use them to review requirements and failure modes only. Do not cite them as customer, model, hardware, or business evidence.

Production Deployment

docs/production/ covers deployment considerations that would need site-specific validation before use:

Runbook Topic
edge-deployment.md ONNX/TensorRT export, Jetson deployment, INT8 quantization trade-offs
model-serving.md Triton vs FastAPI vs ONNX Runtime Server; picking Triton
mes-scada-integration.md OPC-UA, MQTT, PLC signal flow into the detection service
monitoring-drift.md Monitoring deployed models: confidence drift, re-evaluation cadence
labeling-pipeline.md Active learning with human-in-the-loop label capture

Edge & Integration

  • edge/jetson-orin/ β€” Jetson-specific Dockerfile, systemd unit, setup script, watchdog.
  • serving/triton/ β€” Triton Inference Server model repository config for the weld_defect model.
  • integrations/ β€” reference integrations for OPC-UA, MQTT, Kafka, REST webhook.

Model Governance

governance/ follows industry-standard artifacts:

  • model-card.md β€” Google-style Model Card (intended use, training data, evaluation, limitations).
  • data-sheet.md β€” Gebru-style Datasheet for Datasets.
  • Ethics review β€” worker-monitoring implications, false-positive/negative cost framing.

Benchmarks

benchmarks/ contains runnable latency and accuracy harnesses. The committed files under benchmarks/results/ are explicitly labeled hand-authored fictional fixtures; they are not runner output or performance evidence.

Generate a measured local latency report only when you have a real checkpoint and can record the environment:

python benchmarks/latency_benchmark.py \
  --model-path checkpoints/best.pt \
  --batch-sizes 1 2 4 8 16 \
  --output benchmarks/results/my-machine-latency.json

See benchmarks/README.md for the evidence boundary and accuracy command.

Related Projects

Project Relationship
retina-scan-ai Sibling vision project β€” medical imaging classification with Grad-CAM
AegisOps Operator handoff and incident analysis β€” directly applicable to plant floor escalation
Nexus-Hive Analytics layer consuming defect telemetry for trend analysis
enterprise-llm-adoption-kit Shared governance patterns (audit, RBAC) applicable to MES integration

Cloud + AI Architecture

Enterprise Productization

  • Product operating model defines the product scope, trust boundary, operating checks, and service path for this repository.

System Architecture

  • System architecture maps the runtime boundary, data/control flow, cloud or local deployment surface, and operating assumptions for this repository.

Service Architecture

  • Service architecture defines the cloud resources, account information, cost controls, and production guardrails needed to turn this repo into a scoped service without publishing public financial assumptions.

Search And Service Surface

Free Resource, Advertising, and Aggregate Data

  • Public utility and architecture checklist
  • Revenue model: contextual advertising on the policy-eligible central resource page.
  • Aggregate value: anonymous aggregate industrial vision validation interest and worksheet usage counts
  • Boundary: ads allowed only on public validation resources; image uploads, inference results, defect records, and dashboards are ad-free
  • Consent defaults off, DNT/GPC fail closed, and personal or sensitive data is never sold.

About

Industrial weld-defect vision reference with synthetic case narratives, model-governance templates, and edge-serving architecture.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages