[CVPR 2026] Official repository for the paper "LEMON: A Large Endoscopic MONocular Dataset and Foundation Model for Perception in Surgical Settings".
[CVPR 2026] Official repository for the paper "LEMON: A Large Endoscopic MONocular Dataset and Foundation Model for Perception in Surgical Settings".
Star ⭐ us if you like it!
This is the official repository for the paper "LEMON: A Large Endoscopic MONocular Dataset and Foundation Model for Perception in Surgical Settings".
This repository provides open access to the LEMON dataset, LemonFM foundation model, and training code.
LEMON is a dataset of over 4K surgical high-resolution videos totaling 938 hours from 35 diverse surgical procedure types. Each video is annotated for multi-label classification, indicating the surgical procedures carried out in the video, and for binary classification, indicating if it is robotic or non-robotic. The dataset's annotations can be found in labels.json.
LemonFM is a foundation model for surgery, it receives an image as input and produces a feature vector of 1536 features as output.
If you use our dataset, model, or code in your research, please cite our paper:
@InProceedings{Che_2026_CVPR_LEMON,
author = {Che, Chengan and Wang, Chao and Vercauteren, Tom and Tsoka, Sophia and Garcia-Peraza-Herrera, Luis C.},
title = {LEMON: A Large Endoscopic MONocular Dataset and Foundation Model for Perception in Surgical Settings},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2026},
pages = {42659-42669}
}Traditional open-access datasets focusing on surgical procedures are often limited by their small size, typically consisting of fewer than 100 videos and less than 30 hours of footage, which leads to poor model generalization. To address this constraint, a new dataset called LEMON has been compiled using a novel aggregation pipeline that collects high-resolution videos from online sources. Featuring an extensive collection of over 4K surgical videos totaling 938 hours (85 million frames) of high-quality footage across multiple procedure types, LEMON offers a comprehensive resource surpassing existing alternatives in size and scope, including two novel downstream tasks. To demonstrate the effectiveness of this diverse dataset, we introduce LemonFM, a foundation model pretrained on LEMON using a novel self-supervised augmented knowledge distillation approach. LemonFM consistently outperforms existing surgical foundation models across four downstream tasks and six datasets, achieving significant gains in surgical phase recognition (+9.5pp, +9.4pp, and +8.4pp of Jaccard in AutoLaparo, M2CAI16, and Cholec80), surgical action recognition (+4.4pp of mAP in CholecT50), surgical tool presence detection (+5.3pp and +10.2pp of mAP in Cholec80 and GraSP), and surgical semantic segmentation (+8.3pp of mDice in CholecSeg8k). LEMON and LemonFM will serve as foundational resources for the research community and industry, accelerating progress in developing autonomous robotic surgery systems and ultimately contributing to safer and more accessible surgical care worldwide.
Install the following dependencies in your local setup:
git clone [email protected]:visurg-ai/LEMON.git
cd LEMON && pip install -r requirements.txtModels used in data curation. We provide the models used in our data curation pipeline to assist with constructing the LEMON dataset, including video storyboard classification models, frame classification models, and non-surgical object detection models. The models can be downloaded from LEMON curation models.
Researchers working in academic institutions can request direct access to the full LEMON dataset for non-commercial purposes by filling the request form in our Website and HuggingFace)
You can use our code of the data curation pipeline and provided annotation file ("labels.json") to recreate the whole LEMON dataset.
Get your YouTube cookie:
You need to provide a "cookies.txt" file if you want to download videos that require Youtube login.
Use the cookies extension to export your Youtube cookies as "cookies.txt".
Download the annotation file ("labels.json") and use the video downloader to download the original selected Youtube videos.
python3 src/video_downloader.py --video-path '../labels.json' --output 'your path to store the downloaded videos' --cookies 'your YouTube cookie file'Curate the downloaded original videos as LEMON video dataset. In detail, use the video_processor to classify each frame as either 'surgical' or 'non-surgical', then remove the beginning and end segments of non-surgical content from the videos, and mask the non-surgical regions in 'surgical' frames and the entire 'non-surgical' frames.
python3 src/video_processor.py --input 'your original downloaded video storage path' --input-json '../labels.json' --output 'your path to store the curated videos and their corresponding frame annotation files' --classify-models 'frame classification model' --segment-models 'non-surgical object detection models'Process the LEMON video dataset as LEMON image dataset (For foundation model pre-training).
python3 src/create_lmdb_LEMON.py --video-folder 'your directory containing the curated videos and their corresponding frame annotation files' --output-json 'your path for the json file to verify the videos and labels alignment' --lmdb-path 'your lmdb storage path'The video processing pipeline leading to the clean videos in the LEMON dataset is as follows:
Model Checkpoints:
You can download the LemonFM full checkpoint which contains backbone and projection head weights for both student and teacher networks at LemonFM.
Pretraining Execution:
To launch the pretraining routine, use torch.distributed.run. Ensure the --data_path and --output_dir parameters are mapped to your local environment.
python3 -m torch.distributed.run --nproc_per_node=8 --nnodes=1 lemonfm/lemonfm.py --arch convnext_large --data_path 'LEMON dataset lmdb path' --output_dir 'your path to store the trained foundation model' --batch_size_per_gpu 40 --num_workers 10Data Preparation
LMDB is used by default for efficient data loading. Convert raw datasets with the following script:
python src/create_lmdb.py \
--image-folder [RAW_DATA_ROOT]/AutoLaparo/frames \
--label-json [RAW_DATA_ROOT]/AutoLaparo/AutoLaparo.json \
--lmdb-path [LMDB_OUTPUT_ROOT]/AutoLaparo \
--image-size 224 224Fine-tuning and Evaluation
The following scripts provide Fine-tuning and evaluation code for LemonFM using a linear head for surgical phase recognition, tool presence detection, and action recognition. For integrating fine-tuned LemonFM with a TCN head, refer to the official TeCNO repository.
Surgical phase recognition:
python3 downstream/train_phase_recognition_autolaparo.py --lr 1e-3 --opt adamW --nepochs 100 --bs 512 --cpdir 'path/to/store/checkpoint' --logdir 'path/to/store/log' --lmdb 'path/to/downstream_task/lmdb' --labels 'path/to/downstream_task/annotation' --seed 30 --pretrained-weights 'path/to/our/LemonFM.pth'
python3 downstream/test_phase_recognition_autolaparo.py --lmdb 'path/to/downstream_task/lmdb' --models 'path/to/your/cpdir' --labels 'path/to/downstream_task/annotation'Surgical tool presence detection:
python3 downstream/train_tool_detection.py --lr 1e-4 --opt adam --nepochs 50 --bs 256 --cpdir 'path/to/store/checkpoint' --logdir 'path/to/store/log' --cpint 5 --kfold 5 --lmdb 'path/to/downstream_task/lmdb' --labels 'path/to/downstream_task/annotation' --seed 42 --pretrained-weights 'path/to/our/LemonFM.pth'
python3 downstream/test_tool_detection.py --lmdb 'path/to/downstream_task/lmdb' --labels 'path/to/downstream_task/annotation' --models 'path/to/your/cpdir' --bs 256 --kfold 5 --pretrained-weights 'path/to/our/LemonFM.pth'Surgical action recognition:
python3 downstream/train_cholecT50_action.py --lr 1e-4 --opt adam --nepochs 50 --bs 256 --cpdir 'path/to/store/checkpoint' --logdir 'path/to/store/log' --cpint 5 --kfold 5 --dataset-dir 'path/to/CholecT50/dataset' --pretrained-weights 'path/to/our/LemonFM.pth'
python3 downstream/test_cholecT50_action.py --dataset-dir 'path/to/CholecT50/dataset' --models 'path/to/your/cpdir' --bs 256 --kfold 5 --pretrained-weights 'path/to/our/LemonFM.pth'import torch
from PIL import Image
from model_loader import build_LemonFM
# Load the pre-trained LemonFM model
LemonFM = build_LemonFM(pretrained_weights = 'your path to the LemonFM')
LemonFM.eval()
# Load the image and convert it to a PyTorch tensor
img_path = 'path/to/your/image.jpg'
img = Image.open(img_path)
img = img.resize((224, 224))
img_tensor = torch.tensor(np.array(img)).unsqueeze(0).to('cuda')
# Extract features from the image
outputs = LemonFM(img_tensor)Based on the annotation of the LEMON dataset, we propose two novel surgical downstream tasks:
Leaderboard for the proposed tasks
To establish a baseline for the two tasks proposed in LEMON, we conducted an evaluation of SotA approaches, which serves as a benchmark for future research endeavors.
Method
Procedure type
Surgery type
mAP (%)
F1-score (%)
Accuracy (%)
F1-score (%)
SlowFast
22.0
23.9
88.5
87.5
TimeSformer
42.1
37.5
93.2
92.7
MViTv2
49.5
41.8
95.8
94.6
Video Swin Transformer
51.4
47.9
98.8
98.7
LemonFM-Vid (ours)
57.8
49.3
98.9
98.9Sources. Our data collection targeted videos from medical institutions and surgeons, aiming to maximize compliance with professional consent standards.
Curation and identifiability. During data curation we spent a total of 106 hours annotating an
No open issues yet, or sync has not completed.