This project builds a CNN-based classifier for semiconductor wafer map defects and emphasizes reliable evaluation under extreme class imbalance (majority “none” vs rare defect types). The key takeaway is that overall accuracy can be misleading, so we report per-class metrics, macro averages, and confusion matrices to assess real defect-detection performance.
In manufacturing inspection (including Edge AI deployments), defect classes are often rare. A model can achieve high overall accuracy by predicting the majority class, but still fail to catch important defects. This repo demonstrates:
- Class-imbalance-aware training (class weights, stratified splits)
- Robust evaluation beyond accuracy (per-class recall, macro F1)
- Practical observations + improvement ideas for production settings
Wafer map images (small, low-resolution grids) labeled into multiple defect categories plus a dominant “none” class.
Notes:
- Some classes may be removed if there are too few samples to train/validate reliably (e.g., single-sample categories).
- Convolutional Neural Network (CNN) for multi-class classification
- Stratified train/val/test split
- Class weighting to reduce majority-class bias
- Data augmentation to improve generalization
- Early stopping and learning-rate scheduling (if enabled)
- Confusion matrix (raw + normalized)
- Per-class accuracy / recall
- Macro vs weighted metrics (macro highlights minority-class performance)
- High overall accuracy is possible due to the dominant “none” class.
- Minority defect classes are harder and may show lower recall.
- The repo focuses on diagnosing these failure modes and showing how to evaluate correctly.
If you have a requirements.txt:
pip install -r requirements.txt
If not, typical dependencies:
pip install numpy matplotlib scikit-learn opencv-python tensorflow
2) Run training / evaluation
Update the command below to match your main script name:
python wafer_defect_classification.py
Outputs typically include:
Training curves (loss/accuracy)
Confusion matrix figures
Classification report
Repo structure (recommended)
.
├── wafer_defect_classification.py # main training + evaluation script
├── README.md
├── requirements.txt
├── images/ # saved plots (confusion matrix, curves)
└── data/ # optional (NOT recommended to upload raw dataset)
Future improvements
Focal loss to emphasize hard / minority examples
Oversampling (SMOTE/ADASYN) or pre-generated augmentation
Two-stage model: defect vs none, then defect type
Transfer learning or self-supervised pretraining (if higher-res inputs available)