To train a CosPlace model, use the train.py script. You must provide paths to the SF-XL dataset folders. The script automatically handles splitting the dataset into CosPlace Groups and caches the result in a cache folder.
By default, the script uses a ResNet-18 backbone with 512-dimensional descriptors, which requires less than 4GB of VRAM.
Key Options:
--backbone: Specify the architecture (e.g., ResNet50).--fc_output_dim: Set the dimensionality of the output descriptors.--use_amp16: Enable Automatic Mixed Precision (AMP) to speed up training (note: the original paper results did not use AMP).
Run python3 train.py -h to view all available hyperparameters.
# Basic training with SF-XL dataset
python3 train.py --train_set_folder path/to/sf_xl/raw/train/database --val_set_folder path/to/sf_xl/processed/val --test_set_folder path/to/sf_xl/processed/test
# Training with a custom backbone and descriptor dimension
python3 train.py --backbone ResNet50 --fc_output_dim 128
# Training with Automatic Mixed Precision (AMP)
python3 train.py --use_amp16