mazurowski-lab / finetune-SAM

This is an official repo for fine-tuning SAM to customized medical images.
https://arxiv.org/abs/2404.09957
Apache License 2.0
114 stars 17 forks source link

Unable to run train_singlegpu_demo.sh #9

Closed thanushipeiris closed 3 months ago

thanushipeiris commented 3 months ago

I am unable to run the example as given in your READ.ME

I'm on a linux machine and follow these steps

git clone "https://github.com/mazurowski-lab/finetune-SAM.git"
cd finetune-SAM
conda env create -f environment.yml
conda activate hg_proj
bash train_singlegpu_demo.sh

Which gives this error

/miniconda3/envs/hg_proj/lib/python3.11/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: '/miniconda3/envs/hg_proj/lib/python3.11/site-packages/torchvision/image.so: undefined symbol: _ZN3c104cuda20CUDACachingAllocator9allocatorE'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
  warn(
usage: SingleGPU_train_finetune_noprompt.py [-h] [-net NET] [-arch ARCH] [-baseline BASELINE]
                                            [-dataset_name DATASET_NAME] [-img_folder IMG_FOLDER]
                                            [-mask_folder MASK_FOLDER] [-finetune_type FINETUNE_TYPE]
                                            [-normalize_type NORMALIZE_TYPE] [-dir_checkpoint DIR_CHECKPOINT]
                                            [-num_cls NUM_CLS] [-epochs EPOCHS] [-sam_ckpt SAM_CKPT] [-type TYPE]
                                            [-vis VIS] [-reverse REVERSE] [-pretrain PRETRAIN] [-val_freq VAL_FREQ]
                                            [-gpu GPU] [-gpu_device GPU_DEVICE] [-sim_gpu SIM_GPU]
                                            [-epoch_ini EPOCH_INI] [-image_size IMAGE_SIZE] [-out_size OUT_SIZE]
                                            [-patch_size PATCH_SIZE] [-dim DIM] [-depth DEPTH] [-heads HEADS]
                                            [-mlp_dim MLP_DIM] [-w W] [-b B] [-s S] [-if_warmup IF_WARMUP]
                                            [-warmup_period WARMUP_PERIOD] [-lr LR] [-uinch UINCH] [-imp_lr IMP_LR]
                                            [-weights WEIGHTS] [-base_weights BASE_WEIGHTS] [-sim_weights SIM_WEIGHTS]
                                            [-distributed DISTRIBUTED] [-dataset DATASET] [-thd THD] [-chunk CHUNK]
                                            [-num_sample NUM_SAMPLE] [-roi_size ROI_SIZE]
                                            [-if_update_encoder IF_UPDATE_ENCODER]
                                            [-if_encoder_adapter IF_ENCODER_ADAPTER]
                                            [-encoder-adapter-depths ENCODER_ADAPTER_DEPTHS]
                                            [-if_mask_decoder_adapter IF_MASK_DECODER_ADAPTER]
                                            [-decoder_adapt_depth DECODER_ADAPT_DEPTH]
                                            [-encoder_depth_layer ENCODER_DEPTH_LAYER]
                                            [-if_encoder_lora_layer IF_ENCODER_LORA_LAYER]
                                            [-if_decoder_lora_layer IF_DECODER_LORA_LAYER]
                                            [-encoder_lora_layer ENCODER_LORA_LAYER]
                                            [-if_split_encoder_gpus IF_SPLIT_ENCODER_GPUS] [-devices DEVICES]
                                            [-gpu_fractions GPU_FRACTIONS] [-evl_chunk EVL_CHUNK]

SingleGPU_train_finetune_noprompt.py: error: unrecognized arguments: -train_img_list ./datasets/MRI-Prostate/train_5shot.csv -val_img_list ./datasets/MRI-Prostate/val_5shot.csv

I have not changed your code in any way. This may be an issue with my system but I am able to use environments otherwise I have also attempted to delete the libpng requirement from environment.yml but that does not help.

Would appreciate it if you could explain what is going wrong

Guhanxue commented 3 months ago

Hi,

Thanks so much for pointing out the issues on your side. It seems the enviroment is just a warning and the main issue is when i updated my configs i forgot to updated the cfg.py. I have just updated cfg.py and also add another requirements.txt file that you can install environment using 'pip install' as well. Hope these updates can solve your issue.