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

I want to get custom input and output sizes #10

Closed GZ-YourZY closed 2 months ago

GZ-YourZY commented 3 months ago

This is a great work, but I have some questions. Since the size of my custom dataset is 608, I hope that the input and output sizes of the loaded images are both 608*608, but the code requires the input size to be 1024 and the output size to be 256, which will have a great impact on performance. Which parts should I modify to get the expected input and output sizes?

haoyudong-97 commented 3 months ago

The input and output sizes are defined by SAM. One appropriate way to fix your issue is to resize your input to the desired size as required.

If you want to overwrite the input/output size, you can go to models/sam/modeling/image_encoder.py and models/sam/modeling/mask_decoder.py to change the img_size parameter. However, this means the network architecture will also be changed and thus most of the pre-trained weights cannot be loaded, which could affect the performance.