Abstract
MemSeg is a semi-supervised framework for industrial surface defect detection that treats the problem as a direct segmentation task. By integrating a memory pool of normal patterns with a synthetic anomaly simulation strategy, MemSeg learns to distinguish between normal and abnormal features effectively. The model utilizes a U-Net architecture with a ResNet18 encoder, achieving state-of-the-art performance on the MVTec AD dataset with significant improvements in inference speed compared to existing embedding-based methods. MemSeg processes approximately 31 images per second, making it a viable solution for real-time industrial applications.
Introduction
In industrial manufacturing, detecting surface defects such as scratches, smudges, and cracks is critical for quality control. However, supervised learning is often impractical because defects are rare and unpredictable. Consequently, researchers have turned to semi-supervised learning, training models exclusively on "normal" samples.
Existing approaches typically fall into two categories: reconstruction-based methods (e.g., Autoencoders or GANs) and embedding-based methods. Reconstruction-based models often suffer from the "generalization trap," where they inadvertently reconstruct defects perfectly, making them undetectable. Embedding-based methods, while accurate, often require computationally expensive pixel-by-pixel matching, which is too slow for high-speed production lines. MemSeg addresses these challenges by combining the accuracy of embedding methods with the end-to-end speed of a segmentation network.
Methodology
MemSeg (Memory-based Segmentation network) is built on a U-Net architecture using a ResNet18 encoder. It introduces two core innovations: anomaly simulation and a memory-based feature comparison module.
Anomaly Simulation
To train the model to recognize defects without real-world examples, MemSeg generates synthetic anomalies. It simulates two primary types of defects:
- Textural Anomalies: Created using patterns from the Describable Textures Dataset (DTD).
- Structural Anomalies: Generated by partitioning the input image into a grid and randomly rearranging the segments.
To ensure these simulated defects appear realistically on the foreground of the product, the framework utilizes Perlin noise and foreground masks.
Memory Module and Feature Fusion
MemSeg maintains a Memory Pool of high-level features extracted from a small set of normal training images. During inference, the model compares the features of the input image to those in the memory pool using L2 distance to identify the "best difference" (the closest match in memory).
A Multi-Scale Feature Fusion (MSFF) module and Spatial Attention Maps leverage this difference to guide the decoder. This mechanism directs the network's attention to regions that deviate significantly from stored normal patterns, effectively performing semantic segmentation of anomalies.
Results and Discussion
The model was evaluated on the industry-standard MVTec AD dataset, which includes 15 categories of objects and textures. MemSeg achieved state-of-the-art results with an AUC of 99.56% at the image-level and 98.84% at the pixel-level.
Beyond accuracy, MemSeg's primary advantage is its inference speed. It processes roughly 31 images per second on an NVIDIA RTX 3090, representing a 10x speedup over popular embedding-based methods like PaDiM or SPADE. Experiments on a custom "Toy Dataset" further demonstrated the model's robustness, showing it could identify geometric anomalies even when trained only on irregular Perlin noise.
Conclusion
MemSeg provides a high-speed, high-accuracy solution for industrial defect detection by reframing the problem as a segmentation task guided by memory. While highly effective, its performance is currently sensitive to spatial alignment; for example, it struggles with randomly rotated objects. Future work will focus on improving the model's invariance to rotation and translation to enhance its robustness in unconstrained industrial environments.
Summary updated