MobileSAM-fast-finetuning is a training script designed for MobileSAM, enabling efficient model finetuning on hardware with limited memory without using adapter.
The script has been tested on both Windows and Linux operating systems:
-
Python version: 3.10
-
PyTorch version: 2.1
-
PyTorch Installation: Visit PyTorch's official installation guide to set up PyTorch on your system.
-
Dependencies: Once PyTorch is installed, install the required packages using the command:
pip install -r requirements.txt
- Training Data: Place your training images (JPG format) and corresponding masks (PNG format, same name as the images) in the
./datasets/train
directory.
- Validation Data: Place your validation images (JPG format) and masks (PNG format, same name as the images) in the
./datasets/val
directory.
Run train.py
By default, the checkpoint will be saved at ./logs/
To customize your training settings, such as batch_size, you can modify the configuration file located at ./configs/mobileSAM.json
. Please note that for users of PyTorch versions earlier than 2.1, enabling bf16=true
in the configuration may result in errors.
To use the finetuned MobileSAM model, simply replace the original MobileSAM checkpoint with the newly finetuned one. No additional configuration needed for a seamless transition!
- Resume checkpoint training from the last finetuned checkpoint