Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ Wafer Defect Detection System

End-to-End Deep Learning Microservice for Inline Wafer Defect Pattern Classification in High-Volume Semiconductor Manufacturing

Python 3.13 PyTorch 2.7+ FastAPI Streamlit Docker Accuracy License: MIT

Targeting Applications in Advanced Process Control (APC) & Yield Engineering at Semiconductor Fabs
(LAM Research Β· Micron Technology Β· Applied Materials Β· GlobalFoundries)


πŸ“‹ Table of Contents


πŸ“Š Executive Summary & Key Results

In semiconductor manufacturing, silicon wafers undergo hundreds of photolithography, etching, and chemical-mechanical planarization (CMP) steps. Spatial defect patterns on wafer maps (e.g., Center, Donut, Edge-Ring, Scratch) directly signal specific process equipment faults.

This project delivers a PyTorch Convolutional Neural Network (CNN) pipeline capable of classifying 9 distinct wafer defect patterns from raw sensor die maps, exposed as a FastAPI microservice and an interactive Streamlit dashboard.

Performance Metrics

Metric Score / Benchmark Note
Overall Accuracy 94.2% Evaluated on WM-811K benchmark test split
Macro F1-Score 0.91 Robust performance across extreme class imbalance
Inference Latency < 25 ms Per wafer map (single-channel 64x64 tensor)
Input Map Resolution 64 Γ— 64 Single-channel spatial tensor representation
Supported Defect Classes 9 Classes Center, Donut, Edge-Loc, Edge-Ring, Loc, Near-full, Random, Scratch, none

🏭 Fab Yield Economics & Business Impact

  • Early Scrap Reduction: Detecting systematic tool failure signatures inline (e.g., CMP slurry scratches or edge-bead removal ring defects) prevents processing damaged wafers through costly downstream processing steps.
  • Financial Savings: At an average wafer manufacturing cost of $5,000 per wafer in modern 300mm fabs, catching 100 defective wafers daily saves up to $500,000 per day ($180M+ annually).
  • Automated Root-Cause Diagnosis: Replaces manual inspection by fab yield engineers, reducing mean-time-to-detection (MTTD) from hours to milliseconds.

πŸ–ΌοΈ Dataset & Defect Pattern Visualizations

The system is trained on the benchmark WM-811K dataset, containing 811,457 real semiconductor wafer maps from high-volume production.

Defect Pattern Samples

Below are representative spatial heatmaps of the 9 defect categories:

Defect Pattern Samples

Class Imbalance Strategy

Raw dataset analysis revealed an extreme 5,275:1 imbalance ratio (785,938 none wafers vs 149 Near-full wafers). To solve this:

  1. Stratified Undersampling: Reduced dominant none samples to 10,000 representative maps.
  2. Inverse-Frequency Loss Weighting: Implemented custom weighted Cross-Entropy Loss ($\text{weight}_c \propto \frac{1}{N_c}$) in PyTorch to ensure rare defect classes (Donut, Scratch) are penalized heavily during backpropagation.

🧠 Model Architecture & Training

The core architecture (WaferCNN) consists of 4 convolutional blocks with Batch Normalization, Max Pooling, and Dropout for regularization:

[Input: 1 x 64 x 64]
  β”‚
  β”œβ”€β”€ Conv2D(1β†’32, 3x3) ── BatchNorm ── ReLU ── MaxPool(2x2)  ➜ [32 x 32 x 32]
  β”œβ”€β”€ Conv2D(32β†’64, 3x3) ── BatchNorm ── ReLU ── MaxPool(2x2)  ➜ [64 x 16 x 16]
  β”œβ”€β”€ Conv2D(64β†’128, 3x3) ── BatchNorm ── ReLU ── MaxPool(2x2) ➜ [128 x 8 x 8]
  β”œβ”€β”€ Conv2D(128β†’256, 3x3) ── BatchNorm ── ReLU ── MaxPool(2x2) ➜ [256 x 4 x 4]
  β”‚
  β”œβ”€β”€ Flatten (4096)
  β”œβ”€β”€ Dropout(0.5) ── Dense(512) ── ReLU
  └── Dense(9) ── Softmax ➜ [Class Probabilities]

Training & Validation Curves

Training Curves


πŸ“ˆ Evaluation & Model Explainability (Grad-CAM)

Confusion Matrix

The confusion matrix below highlights strong class separation across all 9 defect types, with low misclassification rates even among topographically similar classes (e.g., Edge-Loc vs Edge-Ring).

Confusion Matrix

Grad-CAM Explainability

Semiconductor engineers require explainable AI before deploying models in production. Grad-CAM (Gradient-weighted Class Activation Mapping) extracts feature maps from the final convolutional layer (conv4), overlaying heatmaps to confirm the network focuses precisely on the die failure regions.

Grad-CAM Visualization


πŸ“ Repository Structure

wafer-defect-detection/
β”œβ”€β”€ api.py                      # FastAPI inference microservice
β”œβ”€β”€ dashboard.py                # Streamlit interactive visualization dashboard
β”œβ”€β”€ Dockerfile                  # Production Docker container configuration
β”œβ”€β”€ requirements.txt            # Python environment dependencies
β”œβ”€β”€ label_mapping.json          # Class label integer-to-name mapping
β”œβ”€β”€ best_wafer_model.pth        # Saved PyTorch CNN model weights (~9.9 MB)
β”œβ”€β”€ defect_samples.png          # Visual sample grid
β”œβ”€β”€ training_curves.png         # Loss and accuracy curves
β”œβ”€β”€ confusion_matrix.png        # Evaluation confusion matrix
β”œβ”€β”€ gradcam_visualization.png   # Grad-CAM model explainability plot
β”œβ”€β”€ LICENSE                     # MIT Open Source License
β”œβ”€β”€ LINKEDIN_POST.md            # LinkedIn post template for project showcase
└── README.md                   # Project documentation

πŸ’» Tech Stack

  • Deep Learning Framework: PyTorch 2.7+ (CUDA GPU accelerated)
  • Computer Vision: OpenCV, Pillow
  • Web API / Serving: FastAPI, Uvicorn, ASGI
  • Frontend Dashboard: Streamlit, Plotly Express
  • Containerization: Docker
  • Data Engineering: Pandas, NumPy, Scikit-learn, Matplotlib, Seaborn

πŸš€ Quick Start Guide

1. Local Execution with Conda

# Clone repository
git clone https://github.com/yourusername/wafer-defect-detection.git
cd wafer-defect-detection

# Activate environment & install requirements
conda activate wafer-env
pip install -r requirements.txt

# Terminal 1: Launch FastAPI backend server
uvicorn api:app --reload --port 8000

# Terminal 2: Launch Streamlit frontend dashboard
streamlit run dashboard.py

Access the Streamlit Dashboard at http://localhost:8501 and FastAPI interactive Swagger documentation at http://localhost:8000/docs.

2. Docker Deployment

# Build Docker image
docker build -t wafer-defect-api .

# Run container
docker run -p 8000:8000 wafer-defect-api

# Health check
curl http://localhost:8000/health

πŸ”Œ REST API Endpoints

GET /health

Returns microservice operational status and model version.

{
  "status": "healthy",
  "model": "WaferCNN v1.0"
}

POST /predict

Accepts an uploaded wafer image file (multipart/form-data) and returns predicted defect class with confidence distribution.

Sample JSON Response:

{
  "predicted_class": "Edge-Ring",
  "confidence": 0.9842,
  "all_probabilities": {
    "Center": 0.0011,
    "Donut": 0.0005,
    "Edge-Loc": 0.0082,
    "Edge-Ring": 0.9842,
    "Loc": 0.0021,
    "Near-full": 0.0001,
    "Random": 0.0008,
    "Scratch": 0.0015,
    "none": 0.0015
  }
}

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.

About

End-to-End Deep Learning (PyTorch) Microservice & Streamlit Dashboard for Inline Semiconductor Wafer Defect Pattern Classification (WM-811K)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages