██╗ ██╗██████╗ █████╗ ██╗ ██╗██████╗ ███████╗███████╗███████╗ ██████╗████████╗██╗ ██████╗ ╚██╗██╔╝██╔══██╗██╔══██╗╚██╗ ██╔╝██╔══██╗██╔════╝██╔════╝██╔════╝██╔════╝╚══██╔══╝██║██╔═══██╗ ╚███╔╝ ██████╔╝███████║ ╚████╔╝ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║██║ ██║ ██╔██╗ ██╔══██╗██╔══██║ ╚██╔╝ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██║▄▄ ██║ ██╔╝ ██╗██║ ██║██║ ██║ ██║ ██████╔╝███████╗██║ ███████╗╚██████╗ ██║ ██║╚██████╔╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══▀▀═╝
Manual radiographic inspection is slow, inconsistent, and impossible to scale. XRayDefectIQ changes that.
- What It Does
- System Architecture
- Features
- Model Performance
- Project Structure
- Getting Started
- Tech Stack
- Use Cases
- Roadmap
- License
XRayDefectIQ is an end-to-end industrial inspection platform that ingests X-ray images, runs them through a trained YOLO detection engine, isolates and characterizes every defect found, and commits structured records to a MySQL database — all through a single interactive UI. No CV expertise required at runtime.
It's built for real NDT workflows: weld inspection, casting analysis, aerospace radiography, and automated manufacturing QA pipelines where accuracy, traceability, and speed are non-negotiable.
Text representation
┌─────────────────────────────────────────────────────────────┐
│ X-ray Image Input │
└───────────────────────────┬─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Image Enhancement Pipeline │
│ Grayscale · CLAHE · Contrast · Sharpen · Denoise · Edge │
└───────────────────────────┬─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ YOLO Detection Engine │
│ Bounding Boxes · Confidence Scores · Multi-defect │
└───────────────────────────┬─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Defect ROI + Feature Extraction │
│ Texture · Entropy · Skewness · Kurtosis · Pixel Stats │
└───────────────────────────┬─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Inspection Decision Layer │
│ Accept / Reject · Inspector Remarks │
└───────────────────────────┬─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ MySQL Defect Record Storage │
│ Full traceability · Defect ID · Component · Date │
└─────────────────────────────────────────────────────────────┘
| Architecture | Application Flow | Class Structure |
|---|---|---|
![]() |
![]() |
![]() |
- Upload any X-ray image; YOLO handles the rest
- Annotated output with bounding boxes and per-defect confidence scores
- Multi-defect support — catches everything in a single pass
- ROI extraction per detected defect for downstream analysis
Eight enhancement modes to maximize defect visibility before inference:
| Mode | Purpose |
|---|---|
| Grayscale Conversion | Normalize radiographic input |
| Histogram Equalization | Global contrast correction |
| CLAHE | Localized adaptive contrast enhancement |
| Contrast Adjustment | Manual intensity tuning |
| Sharpening | Edge accentuation for subtle defects |
| Noise Reduction | Remove sensor and scatter artifacts |
| Blur Filtering | Smooth out unwanted high-frequency noise |
| Edge Detection | Highlight structural boundaries |
For every detected defect region, the platform computes:
- Statistical metrics — Mean, Variance, Skewness, Kurtosis
- Texture descriptors — Entropy, intensity distribution
- Spatial geometry — Bounding box dimensions, centroid, area
Full model lifecycle management without leaving the app:
- Upload custom labeled datasets directly from the UI
- Trigger YOLO training jobs and watch live progress
- Save trained checkpoints and hot-swap between models
- Supports iterative retraining as defect libraries expand
Every inspection writes a structured, queryable record:
| Field | Description |
|---|---|
| Defect ID | Unique identifier per detection event |
| Component Name | Part under inspection |
| Asset / Satellite | System or assembly context |
| Component Code | Internal part numbering |
| Defect Type | Classification label from the model |
| Accept / Reject | Final disposition |
| Inspector Remarks | Free-text annotation |
| Timestamp | Full datetime of inspection |
Detection metrics from the trained YOLO model evaluated on the held-out test set.
| Training Results | Results Overview |
|---|---|
![]() |
![]() |
Confusion Matrix
| Raw | Normalized |
|---|---|
![]() |
![]() |
Confidence & Recall Curves
| F1–Confidence | Precision–Confidence |
|---|---|
![]() |
![]() |
| Recall–Confidence | Precision–Recall |
|---|---|
![]() |
![]() |
XRayDefectIQ/
│
├── app.py # Main Streamlit interface — all UI and orchestration logic
├── training_handler.py # YOLO training pipeline and model management
├── mysql_handler.py # Database connection, queries, and record insertion
├── DATABASE_SETUP.sql # Schema creation — run once to initialize
│
├── models/ # Trained model weights (.pt files)
├── Training images/ # Labeled dataset for custom training runs
└── assets/screenshots/ # Architecture diagrams and performance metrics
- Python 3.9+
- MySQL 8.x (running locally or remotely)
# 1. Clone the repo
git clone https://github.com/Sanskar121543/XRayDefectIQ.git
cd XRayDefectIQ
# 2. Install dependencies
pip install -r requirements.txtOpen mysql_handler.py and update your MySQL credentials before running anything:
host = "localhost"
user = "your_user"
password = "your_password"
database = "xraydefectiq"mysql -u root -p < DATABASE_SETUP.sqlstreamlit run app.py| Layer | Technology |
|---|---|
| Interface | Streamlit |
| Detection | Ultralytics YOLO (YOLOv8) |
| Image Processing | OpenCV, NumPy |
| Data Handling | Pandas |
| Storage | MySQL |
| Language | Python 3.9+ |
- Weld Inspection — Detect porosity, cracks, and incomplete fusion in weld joints
- Casting Analysis — Identify voids, inclusions, and shrinkage defects in metal castings
- Aerospace Radiography — Audit structural components against stringent tolerance specs
- Manufacturing QA — Integrate into production lines for automated pass/fail decisions
- NDT Research — Build and benchmark custom defect detection datasets
- Cloud deployment (AWS / GCP / Azure)
- Real-time camera and live feed inspection
- PDF inspection report generation
- Role-based access control (RBAC)
- Explainable AI — Grad-CAM heatmap overlays
- Multi-model ensemble inference
Manual radiographic inspection has three problems: it's slow, it's subjective, and it doesn't scale. A single inspector reviewing hundreds of images per shift introduces fatigue-driven variance. There's no audit trail. There's no feedback loop into process improvement.
XRayDefectIQ is built to fix all three. Fast inference over any X-ray image. Consistent, model-driven detection that doesn't drift with fatigue. And a database-backed record for every inspection, so quality teams can actually learn from the data they're collecting.
MIT — use it, fork it, build on it.
Built by Sanskar Shimpi












