A deep-learning-based system for detecting metal surface defects such as cracks, corrosion/rust, scratches, and holes on industrial pipelines. Built using YOLOv8 Nano for real-time, lightweight inference — optimized for edge deployment on devices like the Raspberry Pi.
- Overview
- Features
- Defect Classes
- Dataset
- Project Structure
- Installation
- Usage
- Model Details
- Future Scope
- License
Industrial pipelines are critical infrastructure assets that require regular inspection to prevent catastrophic failures. Manual inspection is time-consuming, expensive, and error-prone. This project automates the detection of surface-level defects using computer vision, enabling faster and more reliable pipeline health assessments.
The system trains a YOLOv8 Nano object-detection model on labeled images of metal surfaces and is designed to run efficiently on resource-constrained hardware for in-field deployment.
- Multi-class defect detection — identifies cracks, rust, scratches, holes, and normal surfaces.
- Lightweight model — YOLOv8 Nano architecture for fast inference on edge devices.
- Edge-ready — optimized image size (320×320) and small batch training for Raspberry Pi deployment.
- Automated labelling — utility script to generate YOLO-format labels from class-organized image folders.
- Roboflow integration — supplementary crack-detection dataset sourced from Roboflow.
| Class ID | Defect Type | Description |
|---|---|---|
| 0 | Crack | Fractures or fissures on the surface |
| 1 | Hole | Punctures or perforations in the metal |
| 2 | Rust | Corrosion or oxidation patches |
| 3 | Scratch | Surface abrasions or score marks |
| 4 | Normal | Defect-free surface (healthy baseline) |
The project uses a combination of:
- Custom industrial defect dataset — images organized by class into
train/andval/splits with YOLO-format bounding-box labels. - Roboflow crack dataset — 1,551 annotated crack images exported in YOLOv8 format (no augmentation applied).
dataset/
├── images/
│ ├── train/ # Training images
│ └── val/ # Validation images
├── labels/
│ ├── train/ # Training labels (YOLO format)
│ └── val/ # Validation labels (YOLO format)
└── runs/ # Dataset-level experiment runs
Label format (YOLO):
<class_id> <x_center> <y_center> <width> <height>(normalized 0–1)
Pipeline crack detection/
│
├── dataset/ # Images and labels (train/val splits)
├── roboflow_data/ # Supplementary Roboflow crack dataset
├── runs/ # Training run outputs (weights, metrics)
│ └── detect/
│ ├── train/ # First training run
│ └── train-2/ # Second training run
│
├── labelling.py # Auto-generates YOLO labels from folder structure
├── train.py # Model training script
├── data.yaml # Dataset configuration for YOLO
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
└── readme.md # This file
- Python 3.8+
- NVIDIA GPU with CUDA support (recommended for training)
- pip
# Clone the repository
git clone https://github.com/<your-username>/Pipeline-crack-detection.git
cd Pipeline-crack-detection
# Create and activate a virtual environment
python -m venv yoloenv
# Windows
yoloenv\Scripts\activate
# Linux / macOS
source yoloenv/bin/activate
# Install dependencies
pip install -r requirements.txtIf your images are organized by class in a folder structure, use labelling.py to auto-generate YOLO-format label files:
python labelling.pyNote: By default, the script processes images in
industrial_defect_dataset/val/and writes labels toindustrial_defect_dataset/labels/val/. Update thebase_pathandoutput_labelsvariables in the script for your specific paths.
Train the YOLOv8 Nano model using the configured dataset:
python train.pyDefault training configuration:
| Parameter | Value |
|---|---|
| Base model | yolov8n.pt |
| Epochs | 50 |
| Batch size | 8 |
| Image size | 320 × 320 |
| Workers | 2 |
| Device | GPU (device=0) |
| Output | runs/pipeline_defect_model |
Trained weights are saved to runs/detect/pipeline_defect_model/weights/.
| Property | Value |
|---|---|
| Architecture | YOLOv8 Nano (yolov8n) |
| Task | Object Detection |
| Input resolution | 320 × 320 px |
| Number of classes | 5 |
| Framework | Ultralytics |
| Target hardware | Raspberry Pi / edge devices |
- 🎥 Real-time video inference — integrate with a live camera feed for on-site pipeline inspection.
- 📊 Performance benchmarking — evaluate mAP, precision, recall, and inference latency across hardware.
- 🔄 Data augmentation — apply mosaic, mixup, and geometric transforms to improve robustness.
- 🚀 Model export — convert to ONNX / TensorRT / TFLite for accelerated edge inference.
- 🤖 Drone / robot integration — mount the inference pipeline on autonomous inspection platforms.
- 📈 Active learning — iteratively improve the model with newly collected field data.
This project is licensed under the MIT License — see the LICENSE file for details.
Note: The supplementary Roboflow dataset component is under a separate Private license as specified by Roboflow.
Built with ❤️ using Ultralytics YOLOv8