Installation (tested on Ubuntu 20.04.6 LTS x86_64)
git clone https://huggingface.co/ChrisXiao/EndoSAM
cd EndoSAM
conda env create -f environment.yml
conda activate sam
If conda cannot install successfully, try
conda create -y -n sam python=3.10.11
conda activate sam
pip install -r requirements.txt
Usage
Download (using wget or manual way) the SAM model checkpoint and place it into sam_weightsfolder, click the links below to download the checkpoint for the corresponding model type.
cd endoSAM
python train.py --cfg ../config/finetune.yaml
GPU RAM Requirement
Even though this is the fine-tune work, it requires a large GPU RAM. We tested on the EndoVis2017 [1] and EndoVis2018 [2] Dataset and image resolution is 1024 x 1024 with initial processing for the SAM. Use suitable batch size based on the VRAM you have
Batch Size 1 -> 6 GB RAM
Batch Size 2 -> 12 GB RAM
Batch Size 4 -> 21 GB RAM
Batch Size 8 -> 33 GB RAM
The training checkpoints, best model, loss plots and log files will be saved in thelog_folder, model_folder, ckpt_folder and plot_folderyou provide in the config file respectively.
Inference
python test.py --cfg ../config/finetune.yaml
The prediction results will be saved into the test_folder you provide in the config file.