Deep Learning Defect Classification in Automated Visual Inspection
Choosing the right deep learning architecture depends on what the inspection task actually requires.

Deep learning defect classification in automated visual inspection is an engineering choice that includes model training. Reliable inspection depends on matching CNNs, transformers, hybrid detectors, or anomaly-based approaches to the available data, required outputs, and production conditions. Architecture is the starting point, but whether the pipeline can support manufacturing decisions depends on the data it covers, how it assesses severity, and its cross-scenario robustness.
Why automated visual inspection needs more than a trained classifier
A system that flags particle contamination and a scratch identically gives process engineers no basis for distinguishing their causes. Detection is only the first requirement. Inspection may also need to identify the defect category, locate its boundaries at the pixel level, and establish its severity. The IDA 2026 Grand Challenge separates detection, localization, and classification in Track 1 from severity grading in Track 2 because benchmarks that conflate these tasks obscure what models must deliver.
That distinction becomes concrete on semiconductor wafer surfaces. The challenge covers seven defect categories, namely Scratch, Dent, Particle, Damage, Stain, Bubble, and Chipping. A binary decision cannot express this range. Traditional rule-based machine vision needs engineers to hand-code what defects look like, while supervised deep learning learns from labeled examples. Those examples are scarce relative to good parts, inference must run at line speed, and imaging conditions may change after training.
What CNNs do well and where their limits appear in defect classification
CNNs are the workhorse of deployed inspection because successive convolutional layers learn spatial feature hierarchies directly from labeled images. These layers pick out textures, edges, and shapes at different scales, so they can recognize defects across different surface finishes and defect orientations without rules for each appearance. Transfer learning reduces the need to start from scratch. Anusha et al. (2026) use MobileNetV2 pretrained on ImageNet, illustrating how general visual features can support defect classification on resource-constrained hardware with limited industrial data.
Mezher and Marble (2023) demonstrate that highly repetitive manufacturing data can encourage shortcuts that fail on new defect instances or changed conditions. Rare categories create a related problem. With few examples of these defects, models can suppress minority-class predictions and reduce recall on types important to yield and reliability. A classifier can therefore learn the available dataset without learning a sufficiently robust representation of the defect.
Localization provides one response to that fragility. Mezher and Marble show that object detectors predicting both a label and a bounding box outperform label-only classifiers on held-out manufacturing test data. Their result supports treating localization and classification jointly rather than assuming categorization should precede spatial reasoning. It does not make CNNs inadequate. Instead, it shows why a label-only architecture may be poorly matched to the information an inspection task requires.
How transformer-based and hybrid architectures address localization and context
Transformers address spatial relationships through a different mechanism. They process an image as a sequence of patches and use self-attention to relate distant regions. This is useful when a scratch spans several patches or when surrounding context helps distinguish a particle from other surface features. Convolution alone is less direct in how it handles those long-range relationships. Attention therefore offers a response to a specific limitation, rather than simply a larger version of the same classifier.
The challenge paper identifies Mask2Former as a leading method under controlled conditions, illustrating how masked attention supports pixel-level instance segmentation. A box locates a defect without tracing its boundary. Instance segmentation traces that boundary when inspection needs a precise surface map. Hybrid CNN-transformer detectors bring together efficient local feature extraction and global context, which helps when defects in the same category appear at very different scales.
That gain comes with a training cost. Transformers require substantially more labeled data and compute when trained from scratch, which conflicts with rare-defect inspection. Hybrids that reuse CNN-learned features remain attractive under those constraints. The challenge paper reports 2,323 test images with background texture interference, large intra-class morphological variation, and rare defect instances. These conditions expose the limits of fixed-receptive-field convolution and explain the appeal of attention, but they do not remove the need for adequate training data.
What anomaly-based approaches offer when labeled defect data is scarce
When defect labels are insufficient, anomaly detection learns a distribution of normal parts and scores deviations from it instead of learning categories from defective examples. Training requires no labeled defects at all. This makes anomaly detection a viable entry point when conforming parts are plentiful but examples of failure are not. Anusha et al. restructure the MVTec dataset, typically used for unsupervised anomaly detection, into a supervised multi-class framework, illustrating how label availability can change the task supported by the same dataset.
Mezher and Marble note that natural part variation can obscure small defects, with no guarantee that the learned features actually represent defects. An anomaly score also does not ordinarily identify a defect category without additional steps. For process engineers, that leaves an actionable gap between detecting a rejection and distinguishing a particle from a scratch. Anomaly screening can therefore precede supervised categorization once a defect is confirmed.
How teams handle scarce and imbalanced defect data in practice
The general visual features in a pretrained model reduce the labeled-data requirement, making the approach suitable for early deployments or constrained hardware. But minority-class suppression can still occur with pretraining. A dataset can have enough images overall and still have too few examples of a rare defect. Training must thus expose the model to the distinctions it must make, alongside providing enough samples.
Jalayer et al. propose a two-stage framework that combines a GAN-based generation model, GP-WGAN, with an enhanced Faster R-CNN detector. The generator extracts and blends objects from real images to synthesize additional defect samples, then the detector trains on the augmented dataset. Their results show superiority over non-augmented baselines across a range of imbalance severities. Background placement is central to the approach. Synthesized defects are randomly allocated onto defect-free backgrounds, separating defect appearance from its original context and aligning with Mezher and Marble’s argument for learning defects out of context.
Synthetic data still needs a real foundation. Generating useful examples requires some understanding of the defect’s appearance, which depends on real examples being available. Neither augmentation nor transfer learning fully enables training when defect examples are entirely absent. Anomaly-based screening remains relevant in that situation because its training requirement is different. Where inspection data cannot be centralized, federated training is a direction to consider, with deployment still to be established beyond these studies.
Why model outputs must go beyond a class label to support manufacturing decisions
A category label does not establish whether a defect exceeds an actionable threshold. The same category can cover a cosmetic blemish or a critical structural failure, so conflating category and severity can lead to unnecessary scrap or undetected failures. Severity needs its own output design. The challenge defines four industry-standard levels, namely Acceptable, Marginal NG, NG, and Gross NG, and reports 1,156 anomalous test images with severity annotations. Distinguishing adjacent grades requires fine-grained discrimination and ordinal reasoning because the grades have an order.
Anusha et al. use Gradient-Weighted Class Activation Mapping, or Grad-CAM, to show which parts of an image drove a prediction. They also add heuristic severity scoring alongside classification. The two outputs answer different manufacturing questions. Severity helps set the rejection threshold, while an explanation map shows which parts of the image the prediction was based on so they can be checked.
Grad-CAM’s indication of influential pixels provides only a partial characterization of the model’s decision boundary, a limitation important in semiconductor wafer inspection, aerospace, and medical devices, where opaque rejection decisions complicate regulatory or quality-system validation. High-stakes applications therefore need validation that goes beyond looking at activation maps, even when classification accuracy is good enough.
How cross-scenario generalization determines whether a model works in the real factory
Controlled-condition accuracy does not establish cross-scenario reliability. Changes in imaging conditions, wafer texture, illumination, or defect scale can put production images outside the distribution the model saw during training. The challenge paper names domain shift as a major barrier to wider use. A model that performs well in one production scenario can suffer catastrophic degradation when transferred to an unseen domain.
Few-shot generalization makes this problem harder because a new defect type or imaging condition may arrive with only a handful of examples. Mezher and Marble show that diverse backgrounds containing a common defect type improve robustness in new contexts. The defect is learned independently of a particular background. Jalayer et al.’s placement of synthesized defects on varied backgrounds addresses the same weakness while also balancing the dataset. Scarcity and domain shift therefore share a root in insufficient coverage of the training distribution.
Domain adaptation responds by training across source and target domains, but it requires some target-domain data. That data may not exist before a new product line launches. Deployment cannot end at model handoff. A model validated on its training distribution can appear ready and then fail silently as imaging conditions drift. Monitoring confidence distributions over time, rather than relying only on periodic accuracy audits, is consequently an operational requirement for maintaining the inspection pipeline.
Matching architecture, data strategy, and output design to the inspection scenario
For an engineering team selecting a pipeline, the first decision is what the available data can support. With abundant labeled examples across categories, a supervised CNN or hybrid detector is appropriate. With few or no labeled defects, a team can start with anomaly detection on normal samples, then add classification once it has collected enough confirmed defects. Rare categories require a more targeted response. GAN-based augmentation or diverse-background variants can help with minority-class suppression in an otherwise labeled dataset if there are real defect examples to work from.
The next decision is the spatial precision required downstream. A lightweight transferred classifier such as MobileNetV2 suits reject-or-accept decisions on constrained hardware. To identify a category, a team needs multi-class classification or an object detector, which also gives bounding-box output and the benefits of joint-learning shown on held-out manufacturing data. Pixel-level boundaries require instance segmentation. Attention-based architectures suit that need when the task calls for precise boundaries and broader spatial context, but the team must also weigh the training cost.
Standard classification can suffice for binary pass-or-fail requirements, while severity-graded decisions call for ordinal regression or fine-grained classification. High-stakes applications also need to show the reasoning behind predictions and have further validation. Grad-CAM or equivalent saliency overlays support examination without replacing that validation. These requirements distinguish an inspection result that merely names a defect from one that supports an auditable disposition.
Stable imaging on a single product line supports a standard supervised model with confidence-drift monitoring, while varied sites or new products call for domain adaptation and cross-scenario design from the start. A pipeline decision log should record which constraints drove the architecture, data strategy, and outputs. This makes later changes easier to isolate. When production conditions change, the team can revisit the affected decision rather than treat the highest benchmark score as a permanent answer.
Sources
- ICME 2026 Grand Challenge on Cross-Scenario Defect Detection and Fine-Grained Severity Grading for High-Precision Manufacturing
Provided the benchmark structure separating detection/localization/classification from severity grading, the seven defect categories, the test image counts, the four severity levels, and the identification of Mask2Former and domain shift as key challenges.
- Automatic Visual Inspection of Rare Defects: A Framework based on GP-WGAN and Enhanced Faster R-CNN
Provided the two-stage GP-WGAN plus enhanced Faster R-CNN framework for rare defect augmentation, including the background placement strategy and results showing superiority over non-augmented baselines.
- A Novel Strategy for Improving Robustness in Computer Vision Manufacturing Defect Detection
Provided the findings on dataset shortcuts in repetitive manufacturing data, the advantage of joint localization and classification over label-only classifiers, and the role of diverse backgrounds in improving cross-scenario robustness.
- Explainable AI for Automated Industrial Defect Detection: A Transfer Learning Approach with MobileNetV2
Provided the MobileNetV2 transfer learning example for resource-constrained hardware, the Grad-CAM explainability approach, and the heuristic severity scoring alongside classification.


