Abstract
Deep neural networks have shown promising results in disease detection and classification using medical image data. However, they still suffer from the challenges of handling real-world scenarios especially reliably detecting out-of-distribution (OoD) samples. We propose an approach to robustly classify OoD samples in skin and malaria images without the need to access labeled OoD samples during training. Specifically, we use metric learning along with logistic regression to force the deep networks to learn much rich class representative features. To guide the learning process against the OoD examples, we generate ID similar-looking examples by either removing class-specific salient regions in the image or permuting image parts and distancing them away from in-distribution samples. During inference time, the K-reciprocal nearest neighbor is employed to detect out-of-distribution samples. For skin cancer OoD detection, we employ two standard benchmark skin cancer ISIC datasets as ID, and six different datasets with varying difficulty levels were taken as out of distribution. For malaria OoD detection, we use the BBBC041 malaria dataset as ID and five different challenging datasets as out of distribution. We achieved state-of-the-art results, improving 5% and 4% in TNR@TPR95% over the previous state-of-the-art for skin cancer and malaria OoD detection respectively.
Introduction
While deep neural networks are remarkably effective at classifying diseases, they often suffer from overconfidence when presented with data outside their training distribution. In a clinical setting, an AI misclassifying a blurry artifact or an unrelated skin condition as a specific pathology can lead to catastrophic failures. The challenge lies in the infinite nature of "Out-of-Distribution" (OoD) data; it is impossible to train a model on every potential anomaly. This research addresses the need for a robust, unsupervised method to detect these anomalies using only available "In-Distribution" (ID) data.
Methods
The proposed framework enhances a model's "self-awareness" through a three-pronged strategy:
- Generating OoD Surrogates: To simulate OoD data, the authors create "fake" images from ID data. The HideCam method for skin images uses Class Activation Maps (CAM) to identify and replace "cancerous-looking" regions with healthy patches, creating samples near the ID manifold boundary. For malaria, Image-Parts-Permutation shuffles image grids to destroy structural information.
- Metric Learning with Tuplet Loss: Moving beyond standard cross-entropy, the framework employs Tuplet Loss. This objective forces the network to cluster similar ID samples tightly in the feature space while pushing generated OoD surrogates far away.
- K-reciprocal Nearest Neighbors: During inference, the model uses k-reciprocal encoding—a mutual-neighbor consistency check. This requirement for mutual agreement between samples makes the OoD score significantly more robust against outliers than simple distance metrics.
Feature Space and Key Insights
A core insight of this work is that standard softmax probabilities are poor indicators of OoD. By reframing the problem as feature retrieval through metric learning, the model achieves more nuanced detection. The creation of "near-miss" surrogates effectively defines the edges of the ID territory.
Results and Discussion
The method was evaluated using the ISIC 2019 skin cancer dataset and the BBBC041 malaria dataset as In-Distribution, against a variety of "distractor" datasets including ImageNet and specialized sets like "BBOX" (lesions covered by black boxes).
Key achievements include:
- Skin Cancer: A 5% improvement in TNR@TPR95% over previous state-of-the-art methods, reaching a near-perfect 98.66% AUROC on the Derm-skin OoD set.
- Malaria: A 4% improvement in TNR@TPR95%, maintaining high accuracy even when distinguishing healthy cells from infected ones in an OoD context.
- Ablation Studies: Results showed that the synergy of tuplet loss, surrogates, and k-reciprocal ranking is critical; removing any single component led to a significant performance drop.
Conclusion
This unsupervised framework provides a significant step toward reliable medical AI by effectively identifying images it does not recognize. While currently validated on skin and malaria datasets, future work will explore its utility in other clinical domains such as radiology and focus on optimizing computational complexity for large-scale deployment.
Summary updated