This repository contains the code for the NeurIPS 2025 paper: Focus-Then-Reuse: Fast Adaptation in Visual Perturbation Environments.
You can directly install the dependencies using the provided setup.sh file.
./setup.shPlease refer to this page to acquire the API key, and then set the environment variable DASHSCOPE_API_KEY to your API key.
export DASHSCOPE_API_KEY="your-api-key"Please run the following command to download the pretrained SAM 2 model weights:
./src/segment-anything-2-real-time/checkpoints/download_ckpts.shMore details can be found in the official SAM-2 repository.
Below are running commands of running FTR and baseline algorithms.
-
Train the original policy in clean environment using DrQ-v2 algorithm.
Please replace env and task with corresponding arguments (e.g. ./scripts/train.sh franka reach).
./scripts/train.sh env task
The model will be saved in
./log_dir/env_task/algorithm/time/modelfolder. -
Adapt the original policy in the perturbed environment using FTR.
Please first refer to this page to acquire the API key, and then
export DASHSCOPE_API_KEY="your-api-key".Then fill in the
adapt-all.shfile with the corresponding model paths../scripts/adapt-all.sh
-
To run the ablation study, please refer to
./scripts/ablation-*.sh
For more parameter settings, please refer to arguments.py.
If you encounter problems related to rendering, please refer to respiratory of DMC
This code is built on top of the repositorys: DMControl Generalization Benchmark and FTD.
The PPO implementation is based on The 37 Implementation Details of Proximal Policy Optimization.
The DrQ-v2 implementation is based on DrQ-v2.
The SAM implementation is based on SAM-2 real-time.










