This repository contains the implementation of the following paper:
SAM-FNet: SAM-Guided Fusion Network for Laryngo-Pharyngeal Tumor Detection
To fine-tune SAM using LoRA, we recommend following the guidelines provided in the original repository: SAMed.
- Fine-tune SAM:
- Follow the instructions in the SAMed repository to fine-tune SAM with LoRA.
- Generate Local Images:
- After fine-tuning, modify the
crop_image.py
script to suit your requirements. - Run the script to generate local images:
- After fine-tuning, modify the
python crop_image.py
Organize your datasets in the following manner:
datasets/
├── dataset1/
│ ├── global/
│ │ ├── train/
│ │ │ ├── benign/
│ │ │ ├── normal/
│ │ │ └── tumor/
│ │ ├── val/
│ │ │ ├── benign/
│ │ │ ├── normal/
│ │ │ └── tumor/
│ │ └── test/
│ │ ├── benign/
│ │ ├── normal/
│ │ └── tumor/
│ └── local_seg/
│ ├── train/
│ │ ├── benign/
│ │ ├── normal/
│ │ └── tumor/
│ ├── val/
│ │ ├── benign/
│ │ ├── normal/
│ │ └── tumor/
│ └── test/
│ ├── benign/
│ ├── normal/
│ └── tumor/
├── dataset6/
│ └── ...
- Modify the
class_labels
variable in thedataset.py
file to reflect the classes in your dataset. - Run this command to train SAM-FNet.
python train.py --data_dir <Your folder> --save_path <Your output path> --num_classes <Your number of categories for your tasks> --pretrained True --encoder ResNet50
- Replace
<Your folder>
with the path to your dataset. - Replace
<Your output path>
with the directory where you want to save the model checkpoints. - Replace
<Your number of categories for your tasks>
with the number of classes in your classification task.
- Change "classes" in the val.py
- Run this command to test.
python val.py --model_path <Your model path> --encoder ResNet50 --dataset <Your dataset name> --save_path <Your output path>
The code of SAM-FNet is built upon SAMed and DLGNet, and we express our gratitude to these awesome projects.