Federated EndoViT: Pretraining Vision Transformers via Federated Learning on Endoscopic Image Collections

Max Kirchner, Alexander C. Jenke, Sebastian Bodenstedt, Fiona R. Kolbinger, Oliver L. Saldanha, Jakob N. Kather, Martin Wagner, Stefanie Speidel

TL;DR

Building surgical foundation models typically requires pooling massive amounts of sensitive clinical video data, which is often impossible due to strict privacy regulations. This paper introduces FL-EndoViT, a federated learning framework that successfully pretrains a Vision Transformer across decentralized surgical datasets using a Masked Autoencoder (MAE) strategy. By integrating an adaptive optimization technique (FedSAM), the authors overcome severe data heterogeneity to achieve performance that matches or even exceeds traditional centralized training.

What Problem Does This Paper Address?

Surgical Data Science (SDS) aims to use AI to improve intraoperative guidance, workflow automation, and patient outcomes. To do this effectively, models need to generalize across different patient populations, surgical techniques, and hospital equipment. While Foundation Models (FMs) excel at learning these generalized representations, training them requires massive, diverse datasets.

Here lies the paradox: data protection laws like GDPR and HIPAA strictly prohibit aggregating patient videos across multiple institutions into a single centralized server. Federated Learning (FL) offers a way out by training models locally at each hospital and only sharing weight updates. However, surgical video data is notoriously heterogeneous (non-IID)—different hospitals use different camera systems, light settings, and surgical approaches. Standard FL algorithms completely fail to converge under these extreme domain shifts.

Methods

The authors present Federated EndoViT (FL-EndoViT), combining federated learning with self-supervised pretraining.

The FL-EndoViT framework consisting of federated self-supervised pretraining and downstream fine-tuning.

Key components include:

  • Masked Autoencoder (MAE) Pretraining: The model learns by reconstructing images where 75% of the visual patches have been randomly masked out. This dense pixel-level task forces the network to learn robust spatial structures.
  • Adaptive FedSAM (Sharpness-Aware Minimization): This is the secret sauce. Standard optimizers often drive local models into sharp, narrow minima that generalize poorly when averaged. FedSAM explicitly seeks out flat minima in the loss landscape, making the aggregated global model highly resilient to non-IID data variations.
  • Stochastic Weight Averaging (SWA): Applied on the server side during the final pretraining epochs, SWA further smooths the decision boundaries and stabilizes convergence.
  • End-to-End Fine-Tuning: The authors demonstrate that to achieve optimal performance on downstream tasks, the entire backbone must be fine-tuned rather than keeping the pretrained encoder frozen.

Datasets

  • Pretraining: The model was pretrained on the Endo700k dataset collection, a massive aggregation of nine publicly available surgical video datasets (including HeiCo, Cholec80, ESAD, and LapGyn4), split across nine simulated clients to mimic real-world institutional silos.
  • Downstream Evaluation:
    • Surgical Scene Segmentation (SSS): Evaluated on CholecSeg8k.
  • Action Triplet Recognition (ATR): Evaluated on CholecT45.
  • Surgical Phase Recognition (SPR): Evaluated on Cholec80.
  • Out-of-Domain Generalization: Evaluated on the GynSurg dataset for video classification tasks (detecting actions, bleeding, and smoke in gynecological laparoscopy).

Key Insights and Ideas

  • Standard FL Fails on Surgical Video: Traditional aggregation methods like FedAvg, FedMedian, or FedAdam completely collapse during self-supervised pretraining on highly heterogeneous surgical data.
  • The Power of Flat Minima: Optimization matters more than architecture here. Forcing local clients to find flatter loss landscapes via FedSAM is the single enabling factor for successful federated MAE pretraining.
  • The Federated Regularization Effect: Surprisingly, the federated model occasionally outperforms an idealized centralized baseline. Because FL-EndoViT forces the model to learn from diverse, decentralized streams without overfitting to a single co-located dataset, it develops a more versatile feature foundation.

Key Results

  • Pretraining Convergence: As shown in the ablation study, Adaptive FedSAM was the only federated method capable of approximating the centralized baseline's reconstruction performance, while standard FedAvg failed to reconstruct patches accurately.
Pretraining performance comparison across different federated optimization methods.
  • Data-Scarce, High-Resolution Segmentation: In few-shot Surgical Scene Segmentation using just a single high-resolution video for training, FL-EndoViT achieved a mean Intersection over Union (mIoU) of 42.03%, vastly outperforming the centralized baseline's 25.68%.
Few-shot Surgical Scene Segmentation performance across low and high resolutions.
  • Action Triplet Recognition: Under full fine-tuning, FL-EndoViT achieved a mean Average Precision (mAP) of 40.79%, compared to 31.33% for the centralized model.
  • Generalization to Rare Events: When tested on the unseen GynSurg dataset, FL-EndoViT showed superior accuracy in identifying rare but critical events like intraoperative bleeding (82.48% vs 78.12%) and smoke (86.83% vs 86.44%).

Limitations and Future Work

Despite its success, FL-EndoViT has clear trade-offs:

  1. Detail Smoothing: The averaging nature of federated learning tends to smooth out high-frequency spatial details. As a result, the centralized model still holds an advantage in low-resolution settings where sharp edge delineation is crucial.
  2. Compute Intensity: Achieving top performance requires full end-to-end fine-tuning of the 116.66M parameter model, which is computationally expensive for edge devices.
  3. Lack of Temporal Dynamics: The current foundation model operates on static image frames. Since surgery is inherently dynamic, the authors note that future iterations must extend the framework to video-based architectures that jointly model spatial and temporal features.

Summary updated

BibTeX
@misc{kirchner2025federated,
  author = {Max Kirchner and Alexander C. Jenke and Sebastian Bodenstedt and Fiona R. Kolbinger and Oliver L. Saldanha and Jakob N. Kather and Martin Wagner and Stefanie Speidel},
  title = {{Federated EndoViT: Pretraining Vision Transformers via Federated Learning on Endoscopic Image Collections}},
  year = {2025},
  eprint = {2504.16612},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.16612},
}
Figure