Sehastrajit commited on
Commit
613d6a6
·
verified ·
1 Parent(s): f8400cb

Add EfficientNet-B2 defect classifier: weights, model card, eval artifacts

Browse files
LICENSE ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ These model weights were fine-tuned on sample imagery provided by Intel Corporation for the Semiconductor
2
+ Solutions Challenge 2026 (Problem A: Small-Sample Learning for Defect Classification). The underlying
3
+ EfficientNet-B2 backbone (torchvision, ImageNet-pretrained) is used under its original license.
4
+
5
+ This checkpoint is shared for educational and research purposes as a challenge submission artifact. It is not
6
+ an official Intel product, and no rights to the underlying Intel-provided dataset are granted beyond what the
7
+ challenge organizers permit. Contact the repository owner before any commercial use.
8
+
9
+ Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries in the U.S. and/or other
10
+ countries.
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: intel-challenge-dataset
4
+ license_link: LICENSE
5
+ tags:
6
+ - pytorch
7
+ - image-classification
8
+ - efficientnet
9
+ - defect-detection
10
+ - defect-classification
11
+ - semiconductor
12
+ - wafer-inspection
13
+ - manufacturing
14
+ - few-shot-learning
15
+ - small-sample-learning
16
+ - computer-vision
17
+ library_name: pytorch
18
+ pipeline_tag: image-classification
19
+ metrics:
20
+ - accuracy
21
+ - f1
22
+ model-index:
23
+ - name: defect-vision-efficientnet-b2
24
+ results:
25
+ - task:
26
+ type: image-classification
27
+ metrics:
28
+ - type: accuracy
29
+ value: 0.9556
30
+ name: Test accuracy
31
+ - type: accuracy
32
+ value: 0.975
33
+ name: Best validation accuracy
34
+ ---
35
+
36
+ # Defect Vision: EfficientNet-B2 Semiconductor Defect Classifier
37
+
38
+ Fine-tuned EfficientNet-B2 for **small-sample wafer defect classification**, built for the **Intel
39
+ Semiconductor Solutions Challenge 2026, Problem A: Small-Sample Learning for Defect Classification**.
40
+
41
+ Classifies gray-scale wafer/die images into **8 defect classes + "no defect"** (9-way), trained on a
42
+ class-balanced, heavily-augmented small dataset rather than large-scale labeled data. The challenge's core
43
+ constraint is that production defect data is scarce and imbalanced.
44
+
45
+ - **Code, FastAPI service, React demo UI, training notebook:** https://github.com/Sehastrajit-S/defect-vision
46
+ - **Backbone:** `torchvision.models.efficientnet_b2` (ImageNet-pretrained), custom classifier head
47
+ - **Params:** ~9.2M
48
+ - **Input:** 260×260 RGB (gray-scale images converted to 3-channel), ImageNet normalization
49
+
50
+ ## Results
51
+
52
+ | Metric | Target (challenge brief) | Achieved |
53
+ |---|---|---|
54
+ | Overall classification accuracy | ~85% | **95.6%** (test, 360 held-out images) |
55
+ | Best validation accuracy | n/a | **97.5%** |
56
+ | Inference latency | ~1s/image | ~40–500ms/image (GPU), ~0.1–1s (CPU) |
57
+
58
+ <details>
59
+ <summary>Full per-class classification report (test set)</summary>
60
+
61
+ ```text
62
+ Test Loss : 0.6153 | Test Accuracy : 0.9556
63
+
64
+ precision recall f1-score support
65
+
66
+ defect1 0.9773 0.9556 0.9663 45
67
+ defect2 0.9375 1.0000 0.9677 45
68
+ defect3 1.0000 1.0000 1.0000 45
69
+ defect4 1.0000 1.0000 1.0000 45
70
+ defect5 0.9130 0.9333 0.9231 45
71
+ defect8 0.8837 0.8444 0.8636 45
72
+ defect9 0.9556 0.9556 0.9556 45
73
+ defect10 0.9773 0.9556 0.9663 45
74
+ new_good 0.0000 0.0000 0.0000 0
75
+
76
+ accuracy 0.9556 360
77
+ macro avg 0.8494 0.8494 0.8492 360
78
+ weighted avg 0.9555 0.9556 0.9553 360
79
+ ```
80
+
81
+ `new_good` (no defect) has zero held-out samples in this dataset revision. The 9th output neuron is reserved
82
+ for future "no defect found" imagery without requiring re-architecture.
83
+
84
+ </details>
85
+
86
+ ![Confusion matrix](confusion_matrix_test.png)
87
+ ![Training curves](training_curves.png)
88
+
89
+ ## Handling class imbalance with few samples
90
+
91
+ - **Class-balanced dataset construction**: equal train/val/test counts per class (210/45/45) via augmentation,
92
+ instead of naive minority oversampling or loss reweighting, so the model never learns a majority-class prior.
93
+ - **Aggressive augmentation**: random crop, flips, rotation, perspective warp, and color jitter multiply the
94
+ small per-class sample count without duplicating exact pixels.
95
+ - **Label smoothing (0.1)** on cross-entropy keeps the model from over-committing on visually similar defect
96
+ types.
97
+ - **OneCycleLR + early stopping** (patience 7) for fast, stable convergence on limited data. This checkpoint
98
+ converged and early-stopped at epoch 16.
99
+
100
+ ## Usage
101
+
102
+ ```python
103
+ import torch
104
+ import torch.nn as nn
105
+ from torchvision import models, transforms
106
+ from PIL import Image
107
+ from huggingface_hub import hf_hub_download
108
+
109
+ CLASSES = ["defect1", "defect2", "defect3", "defect4", "defect5",
110
+ "defect8", "defect9", "defect10", "new_good"]
111
+
112
+ def build_model(num_classes: int) -> nn.Module:
113
+ model = models.efficientnet_b2(weights=None)
114
+ in_f = model.classifier[1].in_features
115
+ model.classifier = nn.Sequential(
116
+ nn.Dropout(p=0.4),
117
+ nn.Linear(in_f, 512),
118
+ nn.SiLU(inplace=True),
119
+ nn.Dropout(p=0.3),
120
+ nn.Linear(512, num_classes),
121
+ )
122
+ return model
123
+
124
+ weights_path = hf_hub_download(repo_id="Sehastrajit/defect-vision-efficientnet-b2", filename="best_model.pth")
125
+ model = build_model(len(CLASSES))
126
+ ckpt = torch.load(weights_path, map_location="cpu", weights_only=False)
127
+ model.load_state_dict(ckpt["model_state"])
128
+ model.eval()
129
+
130
+ transform = transforms.Compose([
131
+ transforms.Resize((260, 260)),
132
+ transforms.ToTensor(),
133
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
134
+ ])
135
+
136
+ img = Image.open("wafer_sample.png").convert("RGB")
137
+ x = transform(img).unsqueeze(0)
138
+ with torch.no_grad():
139
+ probs = torch.softmax(model(x), dim=1)[0]
140
+
141
+ pred = CLASSES[probs.argmax().item()]
142
+ print(pred, probs.max().item())
143
+ ```
144
+
145
+ ## Training setup
146
+
147
+ | | |
148
+ |---|---|
149
+ | GPU | NVIDIA RTX 3060 12GB (fp16 AMP) |
150
+ | Optimizer | AdamW, lr 2e-4, weight decay 1e-4 |
151
+ | Schedule | OneCycleLR, cosine anneal |
152
+ | Batch | 64 × 2 grad-accum steps (effective 128) |
153
+ | Split | 70% train / 15% val / 15% test |
154
+ | Epochs | early-stopped at 16 (patience 7) |
155
+
156
+ Full training script: [`h1.ipynb`](https://github.com/Sehastrajit-S/defect-vision/blob/main/src/app/h1.ipynb) in
157
+ the main repo.
158
+
159
+ ## Intended use & limitations
160
+
161
+ Built as a challenge submission demonstrating small-sample defect classification technique, not validated for
162
+ production fab deployment. Trained on Intel-provided sample imagery for the Semiconductor Solutions Challenge
163
+ 2026; `new_good` has no held-out evaluation samples in this dataset revision. Intel and the Intel logo are
164
+ trademarks of Intel Corporation or its subsidiaries. This is an independent student project, not an Intel
165
+ product.
best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc5ac651cf9e661ca55942a795d1563d2758a0c0c3cbe8d50dc28319a3643856
3
+ size 34163260
classification_report.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Test Loss : 0.6153 | Test Accuracy : 0.9556
2
+
3
+ precision recall f1-score support
4
+
5
+ defect1 0.9773 0.9556 0.9663 45
6
+ defect2 0.9375 1.0000 0.9677 45
7
+ defect3 1.0000 1.0000 1.0000 45
8
+ defect4 1.0000 1.0000 1.0000 45
9
+ defect5 0.9130 0.9333 0.9231 45
10
+ defect8 0.8837 0.8444 0.8636 45
11
+ defect9 0.9556 0.9556 0.9556 45
12
+ defect10 0.9773 0.9556 0.9663 45
13
+ new_good 0.0000 0.0000 0.0000 0
14
+
15
+ accuracy 0.9556 360
16
+ macro avg 0.8494 0.8494 0.8492 360
17
+ weighted avg 0.9555 0.9556 0.9553 360
confusion_matrix_test.png ADDED
confusion_matrix_val.png ADDED
split_summary.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train": {
3
+ "defect1": 210,
4
+ "defect2": 210,
5
+ "defect3": 210,
6
+ "defect4": 210,
7
+ "defect5": 210,
8
+ "defect8": 210,
9
+ "defect9": 210,
10
+ "defect10": 210
11
+ },
12
+ "val": {
13
+ "defect1": 45,
14
+ "defect2": 45,
15
+ "defect3": 45,
16
+ "defect4": 45,
17
+ "defect5": 45,
18
+ "defect8": 45,
19
+ "defect9": 45,
20
+ "defect10": 45
21
+ },
22
+ "test": {
23
+ "defect1": 45,
24
+ "defect2": 45,
25
+ "defect3": 45,
26
+ "defect4": 45,
27
+ "defect5": 45,
28
+ "defect8": 45,
29
+ "defect9": 45,
30
+ "defect10": 45
31
+ }
32
+ }
training_curves.png ADDED
training_history.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train_loss": [
3
+ 2.1933312461489725,
4
+ 2.1553719974699472,
5
+ 2.0721990971338182,
6
+ 1.8812163693564279,
7
+ 1.4302027429853166,
8
+ 0.9784145218985422,
9
+ 0.7884583825156802,
10
+ 0.6902853545688448,
11
+ 0.6232542821339199,
12
+ 0.5995042261623201,
13
+ 0.5878782681056431,
14
+ 0.5768878437223889,
15
+ 0.5563245608693077,
16
+ 0.5441939581008185,
17
+ 0.5425735553105672,
18
+ 0.542737436862219
19
+ ],
20
+ "train_acc": [
21
+ 0.1619047619047619,
22
+ 0.2702380952380952,
23
+ 0.44821428571428573,
24
+ 0.655952380952381,
25
+ 0.7428571428571429,
26
+ 0.8154761904761905,
27
+ 0.881547619047619,
28
+ 0.9172619047619047,
29
+ 0.9547619047619048,
30
+ 0.9625,
31
+ 0.9678571428571429,
32
+ 0.9648809523809524,
33
+ 0.9791666666666666,
34
+ 0.9851190476190477,
35
+ 0.9845238095238096,
36
+ 0.9833333333333333
37
+ ],
38
+ "val_loss": [
39
+ 2.176660336388482,
40
+ 2.123828093210856,
41
+ 2.002728467517429,
42
+ 1.6516859107547337,
43
+ 1.0096800830629138,
44
+ 0.7460225237740411,
45
+ 0.6595639175838894,
46
+ 0.6276597248183357,
47
+ 0.5659777522087097,
48
+ 0.574584882789188,
49
+ 0.5686059143808153,
50
+ 0.5664335568745931,
51
+ 0.5855459094047546,
52
+ 0.595595407485962,
53
+ 0.5847034321890937,
54
+ 0.5646144628524781
55
+ ],
56
+ "val_acc": [
57
+ 0.2361111111111111,
58
+ 0.5,
59
+ 0.7277777777777777,
60
+ 0.7972222222222223,
61
+ 0.8277777777777777,
62
+ 0.9138888888888889,
63
+ 0.9305555555555556,
64
+ 0.9416666666666667,
65
+ 0.975,
66
+ 0.9638888888888889,
67
+ 0.9611111111111111,
68
+ 0.9694444444444444,
69
+ 0.9611111111111111,
70
+ 0.95,
71
+ 0.9527777777777777,
72
+ 0.9611111111111111
73
+ ]
74
+ }