A General-Purpose Multimodal Foundation Model for Dermatology
First clone the repo and cd into the directory:
git clone https://github.com/SiyuanYan1/PanDerm
cd PanDerm
Then create a conda env and install the dependencies:
conda create -n PanDerm python=3.10 -y
conda activate PanDerm
pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
Download the pre-trained model weights from this Google Drive link.
After downloading, you need to update the model weights path in the code:
- Open the file
PanDerm/LP_Eval/models/builder.py
- Locate line 42
- Replace the existing path with the directory where you saved the model weights:
root_path = '/path/to/your/PanDerm/Model_Weights/'
We've pre-processed the public datasets used in this study to prevent data leakage between splits. To reproduce the results reported in our paper, please use these processed datasets.
If you wish to use our model with your own dataset, please organize it in the same format as these pre-processed datasets.
Dataset | Processed Data | Original Data |
---|---|---|
HAM10000 | Download | Official Website |
BCN20000 | Download | Official Website |
DDI | Download | Official Website |
Derm7pt | Download | Official Website |
Dermnet | Download | Official Website |
HIBA | Download | Official Website |
MSKCC | Download | Official Website |
PAD-UFES | Download | Official Website |
PATCH16 | Download | Official Website |
Note: The processed datasets may differ slightly from those provided on the official websites. To ensure reproducibility of our paper's results, please use the processed data links provided above.
Training and evaluation using HAM10000 as an example. Replace csv path and root path with your own dataset.
nb_classes
: Set this to the number of classes in your evaluation dataset.batch_size
: Adjust based on the memory size of your GPU.percent_data
: Controls the percentage of training data used. For example, 0.1 means evaluate models using 10% training data. Modify this if you want to conduct label efficiency generalization experiments.
cd LP_Eval
CUDA_VISIBLE_DEVICES=0 python linear_eval.py \
--batch_size 1000 \
--model 'PanDerm' \
--nb_classes 7 \
--percent_data 1.0 \
--csv_filename 'PanDerm_results.csv' \
--output_dir "/path/to/your/PanDerm/LP_Eval/output_dir2/ID_Res/PanDerm_res/" \
--csv_path "/path/to/your/PanDerm/Evaluation_datasets/HAM10000_clean/ISIC2018_splits/HAM_clean.csv" \
--root_path "/path/to/your/PanDerm/Evaluation_datasets/HAM10000_clean/ISIC2018/"
Please refer the bash scripts for useage detail for other evaluation datasets. You can choose the model from models, we provided 9 running code to evaluate on 9 public datasets.
cd LP_Eval
bash script/lp.sh