README.md

April 27, 2026 ยท View on GitHub

Bridging Semantics and Geometry: A Decoupled LVLMโ€“SAM Framework for Reasoning Segmentation in Optical Remote Sensing

๐ŸŽ‰ News

๐Ÿ“– Overview

This is the official implementation of Think2Seg-RS, a decoupled framework for reasoning segmentation in remote sensing (RS) imagery.

Our core idea is to decouple high-level semantic reasoning from low-level geometric execution. Specifically, we train an LVLM prompter (e.g., Qwen-2.5-VL) to control a frozen Segment Anything Model (SAM2) via structured geometric prompts. Through a result-oriented reinforcement learning objective, the LVLM learns to translate abstract semantic reasoning into spatially grounded actions, achieving state-of-the-art performance on the EarthReason dataset.

Examples of Think2Seg-RS on the EarthReason dataset:

result show

๐Ÿ› ๏ธ Setup

1. Clone the repository

git clone https://github.com/Thunderstring/Think2Seg-RS
cd Think2Seg-RS

2. Create conda environment and install dependencies for Think2Seg-RS

# Create and activate the environment
conda create -n think2seg-rs python=3.10
conda activate think2seg-rs
# Install dependencies for Think2Seg-RS
bash setup.sh

3. Install SAM2

Note: You can clone the SAM2 repository into any directory. It does not have to be inside the Think2Seg-RS project folder.

# Clone and install SAM2
git clone https://github.com/facebookresearch/sam2.git && cd sam2
pip install -e .
# Download SAM2 Checkpoints
cd checkpoints && \
./download_ckpts.sh && \

๐Ÿš€ Training

Prepare the dataset before training. You can obtain the EarthReason dataset here: EarthReason dataset.

Configure the required environment variables in src/open-r1-multimodal/run_scripts/*.sh:

export MODEL_NAME=Qwen/Qwen2.5-VL-3B-Instruct
export EARTHREASON_ROOT=<your_earthreason_root_path_here>
export SAM_SIZE=small
export SAM_ROOT=<your_sam_root_path_here>
export RUN_NAME=<your_sam_run_name_here>
export CUDA_VISIBLE_DEVICES=0,1
export WANDB_API_KEY=<your_wandb_api_key_here>
# set --report_to to "none" to disable wandb logging

Then run the bash script:

cd src/open-r1-multimodal
bash run_scripts/run_grpo_geo_ultra-qwen-3B.sh

๐Ÿ“Š Evaluation

You can use our provided model weights: Think2Seg-RS-3B and Think2Seg-RS-7B, or train your own model.

Set the required environment variables and run:

cd src/eval
bash run_think2seg-rs_qwen.sh

For zero-shot referring expression segmentation, you can first access the publicly available datasets here: RRSIS-D, RefSegRS, and RISBench.

Once the datasets are downloaded, configure the required environment variables and execute the corresponding bash script. For example, to run zero-shot segmentation on the RRSIS-D dataset:

cd src/eval
bash run_think2seg-rs_rrsisd-zero-shot.sh

๐Ÿค Acknowledgement

Think2Seg-RS is built upon the open-source projects VLM-R1, SAM2, Qwen2.5-VL and SegEarth-R1. We extend our sincere gratitude to the original authors and contributors of these remarkable works.