Downloads · 30 days
0
RamadhanZome/steel-defect-detector-cnn
steel-defect-detector-cnn is a image classification model from RamadhanZome. Use it when you need a label for an image. The card lists the license as mit.
Automated visual inspection of steel surfaces using deep learning to classify manufacturing defects. This project demonstrates an end-to-end pipeline from raw RLE-encoded data to a production-ready model, with a focus…
Downloads · 30 days
0
Access
Public
Updated Feb 18, 2026
Repo size
1.2 MB
Likes
0
Public
Click a slice to open those files.
.pdf1.2 MB · 49%
From the Hugging Face model README
Automated visual inspection of steel surfaces using deep learning to classify manufacturing defects. This project demonstrates an end-to-end pipeline from raw RLE-encoded data to a production-ready model, with a focus on robustness, explainability, and ethical deployment in resource-constrained industrial settings.
This project builds a Convolutional Neural Network (CNN) to identify and classify defects on steel sheet surfaces. The model is trained on the Severstal Steel Defect Detection dataset and optimized for macro-F1 score to ensure balanced performance across defect types. A key design priority is safety-first classification: the model is intentionally biased to catch critical defects (cracks) even at the cost of cosmetic defect precision, reflecting real-world industrial quality control requirements.
Source: Severstal Steel Defect Detection Dataset
Location: data_raw/ directory
train.csv containing RLE-encoded defect masks0: OK (no defect)1: Crack2: Scratch3: Dent4: Other defectsClass Imbalance: Highly skewed distribution. Class 2 (scratch) dominates; Class 1 (crack) is rare. The problem is simplified to single-label classification by assigning each image its first detected defect class.
| Class | Count |
|---|---|
| 1 (Crack) | 897 |
| 2 (Scratch) | 210 |
| 3 (Dent) | 5043 |
| 4 (Other) | 516 |
Designed for Google Colab with GPU acceleration. Run all package installations in a single cell to ensure environment stability.
!pip install -q torch torchvision albumentations optuna grad-cam scikit-learn pandas numpy matplotlib seaborn tqdm pillow streamlit
Hardware: Detects and uses CUDA > MPS > CPU. Tested on Tesla T4 GPU (15 GB VRAM).
Mount Google Drive:
from google.colab import drive
drive.mount('/content/drive')
data_path = '/content/drive/MyDrive/Steel_Defect_Detector_CNN/data_raw'
Set random seeds (Locked at RANDOM_SEED = 42 for reproducibility)
Run pipeline sequentially:
rle_decode() → Decode masksSteelDS → Custom dataset loaderWeightedRandomSamplerOutputs: All artifacts saved to outputs/:
best_steel_resnet50.pt (model checkpoint)train.csv, val.csv, test.csv (splits)confusion_matrix.png, roc.png, gradcam.png (visualizations)A.Compose([
A.HorizontalFlip(p=0.5),
A.RandomRotate90(p=0.5),
A.CLAHE(p=0.3),
A.RandomBrightnessContrast(p=0.5),
A.Normalize(mean=[0.485,0.456,0.406], std=[0.229,0.224,0.225])
])
Baseline: SimpleCNN
Final Model: ResNet50
Best Trial: {'lr': 2.47×10⁻⁵, 'bs': 16, 'freeze': 3, 'scheduler': 'None'}
| Metric | Score |
|---|---|
| Macro-F1 | 0.20 |
| Micro-F1 | 0.16 |
| Accuracy | 0.16 |
| ROC-AUC (macro) | 0.652 |
| ROC-AUC (micro) | 0.359 |
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| OK | 0.37 | 0.19 | 0.25 | 90 |
| Crack | 0.04 | 1.00 | 0.08 | 21 |
| Scratch | 0.98 | 0.11 | 0.20 | 505 |
| Dent | 0.32 | 0.27 | 0.29 | 51 |
Key Insight: Perfect crack recall (1.00) validates the safety-first design. Low precision is an acceptable trade-off for industrial contexts where missing a crack is catastrophic.

Heatmaps confirm the model focuses on actual defect regions, not background artifacts. Builds trust for deployment.
Status: Fails glare robustness goal. Performance degrades under extreme lighting, common in African manufacturing plants with inconsistent power.
Top-20 error gallery reveals:
Recommendation: Improve preprocessing with adaptive contrast enhancement and defect-aware cropping.
Data-Centric Improvements
Model Efficiency
Fairness & Access
MLOps Pipeline
Last Updated: December 2025
Author: Ramadhan Adam Zome
License: MIT