EndoFinder: Online Lesion Retrieval for Explainable Colorectal Polyp Diagnosis Leveraging Latent Scene Representations

Ruijie Yang, Yan Zhu, Peiyao Fu, Yizhe Zhang, Zhihua Wang, Quanlin Li, Pinghong Zhou, Xian Yang, Shuo WangarXiv 2025 · DOI · arXiv

Introduction

Colorectal cancer (CRC) remains a leading cause of mortality worldwide, making the early detection and accurate diagnosis of polyps during colonoscopy a clinical priority. While deep learning has significantly advanced computer-aided diagnosis, current models often function as "black boxes," providing labels without clinical justification. This lack of interpretability hinders physician trust. Furthermore, polyps are inherently 3D structures, yet most AI models rely on single 2D frames, which may miss critical features due to lighting or viewing angles.

EndoFinder addresses these challenges with a novel retrieval-based framework. Instead of simple classification, it adopts a "diagnosis-by-example" approach. By treating polyps as 3D scenes and fusing multiple endoscopic views into a unified latent representation, the system retrieves "digital twins" from a historical database in real-time to support clinical decision-making with tangible evidence.

Methodology

The EndoFinder framework is designed for efficiency and interpretability, consisting of three primary stages:

1. Polyp-aware Image Encoder

To learn robust features without the need for massive manual labeling, the authors employed a self-supervised pre-training strategy. This pipeline combines contrastive learning with a Masked Autoencoder (MAE) task. A key innovation is the use of polyp segmentation masks to guide the reconstruction process, forcing the encoder to prioritize the lesion's features over the surrounding colonic wall.

The self-supervised pre-training pipeline for the polyp-aware image encoder, utilizing patch masking and contrastive loss to focus on lesion features.

2. Scene Representation Transformer (SRT)

EndoFinder conceptualizes each polyp as a "scene" rather than an isolated image. The SRT fuses features from multiple 2D views into a single, unified latent representation. This approach implicitly captures the 3D geometry of the polyp without requiring explicit camera pose data, which is notoriously difficult to obtain during a live procedure.

3. Semantic Hashing and Retrieval

For real-time clinical utility, continuous latent representations are discretized into binary hash codes. This allows for extremely fast similarity searches within a database of historical cases using Hamming distance and a "ball tree" index.

Overview of the EndoFinder framework, illustrating the flow from multi-view image capture to hash-based retrieval of similar historical cases for clinical evidence.

Datasets and Evaluation

The study utilized several datasets, including significant new contributions to the field:

  • Polyp-18k: 17,969 images used for self-supervised pre-training.
  • Polyp-Twin: 200 polyps with two frames each for single-view re-identification.
  • PolypScene-2k: 2,219 polyps used to train the scene encoder.
  • PolypScene-250 (New): A benchmark of 250 polyps with four views each, designed for scene-based re-identification.
  • PolypScene-80: A subset with pathologically confirmed labels (malignant vs. benign) used to evaluate diagnostic performance.

Key Results and Insights

  • Superior Re-identification: EndoFinder-S (the scene-based variant) achieved a Mean Average Precision (µAP) of 0.71, outperforming standard feature-averaging and baseline self-supervised models like Dino and MAE.
  • Diagnostic Accuracy: On the PolypScene-80 dataset, the retrieval-based approach reached an accuracy of 78.75% and an AUC of 85.59%, surpassing fine-tuned supervised models like ResNet50 and DenseNet121.
  • Efficiency and Scalability: Transitioning to binary hash codes resulted in a 4x speedup in retrieval with minimal accuracy loss. As a transductive system, new cases can be added to the database without retraining the entire model.
  • Explainability: By providing "digital twins"—historical cases with known outcomes—the system mirrors clinical consultation, offering interpretable evidence to the endoscopist rather than just a black-box label.

Conclusion and Future Directions

EndoFinder represents a significant shift toward more transparent and robust AI in gastroenterology. While highly effective, the system currently depends on accurate polyp segmentation; future work will explore removing this dependency through weakly-supervised or unsupervised methods. Additionally, integrating multimodal data, such as patient history or electronic health records, could further enhance diagnostic precision in real-world clinical settings.

Summary updated

Abstract

Colorectal cancer (CRC) remains a leading cause of cancer-related mortality, underscoring the importance of timely polyp detection and diagnosis. While deep learning models have improved optical-assisted diagnostics, they often demand extensive labeled datasets and yield "black-box" outputs with limited interpretability. In this paper, we propose EndoFinder, an online polyp retrieval framework that leverages multi-view scene representations for explainable and scalable CRC diagnosis. First, we develop a Polyp-aware Image Encoder by combining contrastive learning and a reconstruction task, guided by polyp segmentation masks. This self-supervised approach captures robust features without relying on large-scale annotated data. Next, we treat each polyp as a three-dimensional "scene" and introduce a Scene Representation Transformer, which fuses multiple views of the polyp into a single latent representation. By discretizing this representation through a hashing layer, EndoFinder enables real-time retrieval from a compiled database of historical polyp cases, where diagnostic information serves as interpretable references for new queries. We evaluate EndoFinder on both public and newly collected polyp datasets for re-identification and pathology classification. Results show that EndoFinder outperforms existing methods in accuracy while providing transparent, retrieval-based insights for clinical decision-making. By contributing a novel dataset and a scalable, explainable framework, our work addresses key challenges in polyp diagnosis and offers a promising direction for more efficient AI-driven colonoscopy workflows. The source code is available at https://github.com/ku262/EndoFinder-Scene.
BibTeX
@misc{yang2025endofinder,
  author = {Ruijie Yang and Yan Zhu and Peiyao Fu and Yizhe Zhang and Zhihua Wang and Quanlin Li and Pinghong Zhou and Xian Yang and Shuo Wang},
  title = {{EndoFinder: Online Lesion Retrieval for Explainable Colorectal Polyp Diagnosis Leveraging Latent Scene Representations}},
  year = {2025},
  eprint = {2507.17323},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.17323},
}
Figure