Defect-Aware Masked Autoencoders for Unsupervised Clustering of Steel Surface Defects

Shrey PatelarXiv 2026 · arXiv

TL;DR

This paper introduces Defect-Aware MAE, a self-supervised framework that clusters steel surface defects with 98.6% accuracy without using a single manual label during training. By combining texture-based masking with HOG (Histogram of Oriented Gradients) reconstruction, the model learns highly discriminative features that outperform traditional contrastive learning baselines like SimCLR.

What Problem Does This Paper Address?

Automated quality inspection is vital in steel manufacturing, but there’s a catch: most high-performing models are supervised, meaning they require thousands of human-annotated images. Labeling industrial defects is not only expensive and time-consuming but also requires domain expertise to distinguish between subtle textures like "crazing" versus "pitted surfaces."

While self-supervised learning (SSL) offers a way to learn from unlabeled data, standard approaches often fall short in industrial settings. Masked Autoencoders (MAEs), which learn by "filling in the blanks" of an image, typically focus on reconstructing raw pixels. However, for steel defects, the most critical information lies in fine-grained textures and edge orientations, which raw pixel reconstruction often fails to prioritize.

Methods

The author proposes a specialized Masked Autoencoder architecture tailored for texture-heavy industrial data. The pipeline consists of three main innovations:

  1. Defect-Aware Masking: Instead of masking patches at random, the model uses "texture energy" (the standard deviation of pixel intensities within a patch). Using a Gumbel top-k sampling strategy, the model preferentially masks patches with high texture energy—the very areas most likely to contain defects. This forces the encoder to learn complex structural patterns rather than just interpolating smooth, empty surfaces.
  2. HOG Reconstruction Target: Rather than predicting raw pixel values, the shallow decoder is tasked with reconstructing Histogram of Oriented Gradients (HOG) descriptors. HOG captures local shape and directional information, making the pretext task much more relevant to identifying physical cracks and scratches.
  3. Intermediate Layer Readout: Interestingly, the author found that the final layer of the Vision Transformer (ViT) isn't always the best for clustering. Instead, the model extracts features by averaging patch tokens from layers 4, 5, and 6, providing a richer representation of the defect characteristics.

For the final clustering, the frozen features are projected into a lower-dimensional space using UMAP and then grouped using Ward clustering (an agglomerative hierarchical method).

Datasets

The study utilizes the NEU-DET (Northeastern University surface defect database), a benchmark in the field.

  • Content: 1,800 grayscale images of hot-rolled steel strips.
  • Categories: Six distinct defect types: Crazing, Inclusion, Patches, Pitted Surface, Rolled-in Scale, and Scratches.
  • Setup: 1,440 images were used for unlabeled pre-training, while 360 held-out images were used to evaluate clustering performance.

Key Insights and Ideas

  • Texture > Pixels: The most significant performance jump came from switching the reconstruction target from pixels to HOG. In ablation studies, this change alone boosted accuracy from roughly 77% to 93%. This suggests that for industrial SSL, what you reconstruct is just as important as how you mask.
  • Making the Task Harder Helps: By intentionally masking the most "interesting" (high-energy) parts of the image, the model is forced to understand the global context of the defect to successfully predict the missing local texture.
  • Clustering vs. Contrastive Learning: The Defect-Aware MAE outperformed SimCLR, a popular contrastive learning method. Unlike SimCLR, which requires pairs of augmented images and careful management of "negative samples" to prevent the model from collapsing, the MAE approach is more stable and yields more linearly separable features.

Key Results

The results on the NEU-DET validation set are impressive for a fully unsupervised method:

  • Accuracy: 98.6% ± 0.2% (Hungarian matched accuracy).
  • Clustering Metrics: Achieved a Normalized Mutual Information (NMI) of 0.968 and an Adjusted Rand Index (ARI) of 0.967.
  • Separability: A Silhouette score of 0.838 indicates very well-defined, tight clusters compared to the SimCLR baseline (0.736).
  • Qualitative Success: Confusion matrices show the model perfectly clustered four out of six defect categories, with only minor confusion between "pitted surfaces" and "crazing."

Limitations and Future Work

While the results are strong, the paper notes a few areas for growth:

  • Prior Knowledge of K: The clustering algorithm was given the number of clusters ($K=6$). In a truly "blind" industrial discovery scenario, determining the optimal number of defect categories automatically remains a challenge.
  • Dataset Scale: While NEU-DET is a standard benchmark, it is relatively small. Testing this architecture on larger, noisier, and more diverse industrial datasets would be a logical next step.
  • Explainability: The author used Grad-CAM++ to visualize what the model "sees." While the model successfully attends to defect regions, further work could integrate these heatmaps into a human-in-the-loop system for real-time quality assurance.

For researchers and engineers in computer vision, this work demonstrates that domain-specific priors—like focusing on texture energy—can significantly enhance the power of general-purpose architectures like Masked Autoencoders.

Summary updated

Abstract

Reliable recognition of steel surface defects is essential for automated quality inspection, but supervised methods require manually annotated images that are costly to produce. This creates a need for methods that can learn useful defect representations directly from unlabelled surface images. This work presents Defect aware MAE, a label free masked autoencoder for clustering steel surface defects. Each image is divided into 196 patches, with 147 masked and 49 processed by a Vision Transformer encoder. Texture energy based masking preferentially hides structurally informative patches, while a shallow decoder reconstructs HOG descriptors that capture local texture and edge orientation. Strong augmentation and an intermediate layer readout are used to form the final image features. Pretraining uses no class labels, bounding boxes, detection branch, or contrastive loss. On the held out NEU DET split, UMAP followed by Ward clustering achieves 98.6% Hungarian matched accuracy, 0.968 NMI, 0.967 ARI, and 0.838 silhouette score. Under an identical encoder and training schedule, it exceeds a SimCLR contrastive baseline in accuracy, NMI, ARI and silhouette scores across 5 seeds.
BibTeX
@misc{patel2026defect,
  author = {Shrey Patel},
  title = {{Defect-Aware Masked Autoencoders for Unsupervised Clustering of Steel Surface Defects}},
  year = {2026},
  eprint = {2611.20645},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.20645},
}
Figure