Introduction
In medical imaging, the scarcity and high cost of labeled anomalous data (e.g., rare diseases or specific lesions) pose a significant challenge for supervised learning. Unsupervised Anomaly Detection (UAD) offers a compelling alternative by training models exclusively on abundant "normal" data to identify deviations. Traditional reconstruction-based methods, such as standard autoencoders, often suffer from "over-generalization," where the model inadvertently learns to reconstruct anomalies, thereby reducing detection sensitivity. This paper introduces MemMC-MAE, a transformer-based masked autoencoder designed to mitigate this issue by enforcing a strict "normality" bottleneck.
The MemMC-MAE Framework
The proposed architecture, Memory-augmented Multi-level Cross-attentional Masked Autoencoder (MemMC-MAE), introduces two key innovations to the standard Masked Autoencoder (MAE) paradigm to ensure it only learns to reconstruct healthy anatomy.
1. Memory-Augmented Self-Attention
The encoder incorporates learnable "memory matrices" that store prototypical patterns of normal anatomy. During the self-attention process, input patches are forced to interact with these memory slots. This constraint ensures that the encoder represents inputs using a vocabulary of "normality," making it inherently difficult for the model to accurately represent anomalous features.
2. Multi-Level Cross-Attentional Decoder
Unlike standard decoders that only utilize the final encoder layer, MemMC-MAE employs a multi-level cross-attention mechanism. The decoder queries all layers of the encoder hierarchy, leveraging both low-level textures and high-level structural information to guide the reconstruction process. This synergy allows the model to better understand the global structure of healthy tissue.
3. High-Ratio Masking
By masking 75% of input image patches, the model is forced to reconstruct the missing regions based on its internal memory of normal anatomy rather than simple local pixel interpolation. This heavy bottleneck prevents the model from "copying" anomalous pixels into the output.
Experimental Evaluation
The model was evaluated across three diverse medical imaging datasets:
- Pneumonia Chest X-ray: 6,480 images for pneumonia detection.
- Covid-X: A large-scale dataset for COVID-19 identification.
- Hyper-Kvasir: 110,079 gastrointestinal images for polyp detection and localization.
Anomaly detection is performed by comparing the original image to the reconstruction using Multi-Scale Structural Similarity (MS-SSIM). Regions with significant deviations are flagged as potential pathologies.
Results and Discussion
MemMC-MAE established new state-of-the-art benchmarks across all evaluated tasks. In pneumonia detection, it achieved an AUC of 0.879, a 10% improvement over previous methods. For COVID-19 detection, the AUC reached 0.917. In the Hyper-Kvasir dataset, the model achieved an AUC of 0.972 and a Mean IoU of 0.419 for localization, significantly outperforming baselines like PaDiM and IGD.
The success of MemMC-MAE stems from the synergy between memory-augmented encoding and multi-level decoding. By restricting the model's "imagination" to known normal patterns, anomalies appear as high-error regions in the reconstruction, making them easily identifiable.
Conclusion and Future Work
MemMC-MAE demonstrates that memory-augmented reconstruction is a powerful tool for medical UAD. While the model is highly effective, future work may focus on optimizing inference speed for real-time clinical applications and further refining the detection of extremely subtle anomalies. Additionally, the architecture shows promise as a self-supervised pre-training task for broader medical imaging applications where labeled data is scarce.
Summary updated