LSGS-Loc: Towards Robust 3DGS-Based Visual Localization for Large-Scale UAV Scenarios
April 27, 2026 ยท View on GitHub
๐ Paper: PDF

This repository contains the code for "LSGS-Loc: Towards Robust 3DGS-Based Visual Localization for Large-Scale UAV Scenarios".
Environment Setup
# 1. Create environment
conda create -n lsgs_loc python=3.10 -y
conda activate lsgs_loc
# 2. Install PyTorch with CUDA 11.8
conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
# 3. Install gsplat example dependencies
cd third_party/gsplat/examples
pip install -r requirements.txt
# 4. Install gsplat
pip install gsplat==1.5.3
# 5. Install remaining dependencies
pip install scikit-image natsort safetensors ninja kornia huggingface_hub einops fast-pytorch-kmeans
After finishing the environment setup, please also follow the AnyLoc demo instructions to download and prepare Cluster Centers:
Data Preparation
We use the GauUScene dataset.
- Project page: GauUScene Dataset
- After downloading, place the dataset under the
data/folder.
Main Scripts
scripts/lsgs_loc_demo.py: full pipeline of the paper method .scripts/lsgs_loc_full_pipeline.py: end-to-end pipeline including data preprocessing (train/test split) and 3DGS training.
Usage
Option A: Run full pipeline from raw COLMAP project
You can directly run scripts/lsgs_loc_full_pipeline.py to obtain localization results from a raw COLMAP dataset.
python scripts/lsgs_loc_full_pipeline.py \
--colmap_project /path/to/your_colmap_scene \
--output_root /path/to/output \
--trainer_cuda_visible_devices 0
Required arguments:
--colmap_project: input COLMAP project root, must containimages/andsparse/0(orsparse/).--output_root: output root directory.
Commonly used optional arguments
--trainer_cuda_visible_devices: GPU id(s) used by training/inference subprocesses (for example0or0,1).--do_resize: enable COLMAP/image resizing before split.--resize_width: max edge when resizing (default1600, currently only1600is supported/recommended).--image_mode: image materialization mode for split subsets,copyorsymlink(defaultcopy).--retrieval_top_k: retrieval top-k (default3).--render_opt_image_size: render optimization size,originalor1600.--force_restart_all: delete existing intermediates and rerun from scratch.
Notes on settings:
--trainer_cuda_visible_devicesandCUDA_VISIBLE_DEVICESare usually interchangeable for this script.- If
--trainer_cuda_visible_devicesis set, you typically do not need to additionally setCUDA_VISIBLE_DEVICES. output_rootwill contain split data, gsplat checkpoints, and final pose results.
Option B (Recommended): Run step-by-step
You can also run each stage manually.
Step 1: Data preprocessing (split raw COLMAP into train/test)
python -m src.utils.split_colmap \
--colmap_project /path/to/your_colmap_scene \
--output_root /path/to/split_output \
--image_mode copy
Preprocessing script arguments
--colmap_project(required): input COLMAP project directory, must containimages/andsparse/0(orsparse/).--output_root(required): output directory wheretrain/,test/, andlist_test.txtwill be generated.--image_mode(optional):copyorsymlink, default iscopy.
This step will generate:
train/COLMAP subsettest/COLMAP subsetlist_test.txttest image list
Step 2: Train 3DGS scene on the training split
After splitting, follow the gsplat project practice to train a 3DGS scene on the train/ subset and obtain the 3DGS checkpoint/scene for localization.
Step 3: Run LSGS-Loc workflow
After preparing train/, test/, and a trained 3DGS representation, run the workflow script directly.
Use checkpoint input:
python scripts/lsgs_loc_demo.py \
--database_root /path/to/split_output/train \
--query_root /path/to/split_output/test \
--output_dir /path/to/workflow_output \
--ckpt /path/to/3dgs_ckpt.pt
Or use PLY input:
python scripts/lsgs_loc_demo.py \
--database_root /path/to/split_output/train \
--query_root /path/to/split_output/test \
--output_dir /path/to/workflow_output \
--ply /path/to/point_cloud_30000.ply
Notes:
- Exactly one of
--ckptor--plymust be provided. --plyexpects the gsplat export format (for example, files saved bysimple_trainer.pyviasave_ply).scripts/lsgs_loc_demo.pyis the user-facing alias of the same workflow implementation.
License
This project is licensed under MIT. See LICENSE for details.
Citation
If you find this project useful, please consider citing:
@article{zhang2026lsgs,
title={LSGS-Loc: Towards Robust 3DGS-Based Visual Localization for Large-Scale UAV Scenarios},
author={Zhang, Xiang and Wang, Tengfei and Xu, Fang and Wang, Xin and Zhan, Zongqian},
journal={arXiv preprint arXiv:2604.05402},
year={2026}
}
Acknowledgements
We gratefully acknowledge the following projects: