VtT: Reclaiming Lost Text Layers for Source-Free Cross-Domain Few-Shot Learning

April 21, 2026 ยท View on GitHub

Official implementation for CVPR 2026 poster paper: "Reclaiming Lost Text Layers for Source-Free Cross-Domain Few-Shot Learning".

๐Ÿ“‹ Overview

This repository presents VtT (teach Vision To learn from Text), a novel method for Source-Free Cross-Domain Few-Shot Learning (SF-CDFSL).

Key Features

  • Source-Free: No access to source domain training data required
  • Cross-Domain: Handles significant domain shifts between source and target
  • Few-Shot: Learns from limited labeled examples (1-shot or 5-shot)
  • Vision-to-Text Bridge: Novel Mamba architecture for cross-modal alignment

๐Ÿ› ๏ธ Environment Setup

Note: Creating a new environment requires matching CUDA versions. The code was developed with CUDA 11.8.

1. Create Conda Environment

conda create -n VtT python=3.10 -y
conda activate VtT

2. Install PyTorch with CUDA Support

# For CUDA 11.8
pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu118

3. Install Mamba Dependencies

pip install mamba-ssm causal-conv1d

4. Install Other Dependencies

pip install -r requirements.txt

5. Install CLIP (OpenAI)

pip install git+https://github.com/openai/CLIP.git

๐Ÿ“ฆ Datasets

  • EuroSAT: Satellite imagery land cover classification
  • CropDisease: Plant disease recognition
  • ISIC: Skin lesion classification (dermatology)
  • ChestX: Chest X-ray disease classification

Please prepare your datasets in the appropriate directory structure before running experiments.

๐Ÿš€ Usage

Training Commands

For EuroSAT and CropDisease:

# 1-shot setting
python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 1 --episodes 800 --dataset EuroSAT

python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 1 --episodes 800 --dataset CropDisease

# 5-shot setting
python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 5 --episodes 400 --dataset EuroSAT

python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 5 --episodes 400 --dataset CropDisease

For ISIC and ChestX:

# 1-shot setting
python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 1 --episodes 800 --dataset ISIC --lr 4e-4 --mamba_lr 1e-3

python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 1 --episodes 800 --dataset ChestX --lr 4e-4 --mamba_lr 1e-3

# 5-shot setting
python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 5 --episodes 400 --dataset ISIC --lr 4e-4 --mamba_lr 1e-3

python main.py --encoder vision --r 16 --alpha 8 --epochs 250 --shot 5 --episodes 400 --dataset ChestX --lr 4e-4 --mamba_lr 1e-3

Key Arguments

ArgumentDescriptionDefault
--datasetDataset name (EuroSAT/CropDisease/ISIC/ChestX)ISIC
--shotNumber of support examples per class (1 or 5)5
--wayNumber of classes per episode5
--episodesNumber of test episodes400
--epochsTraining epochs per episode250
--encoderWhich encoder to fine-tune (vision/text/both)vision
--rLoRA rank16
--alphaLoRA scaling factor8
--lrLearning rate for LoRA parameters2e-4
--mamba_lrLearning rate for Mamba parameters5e-4
--betaGradient projection coefficient7
--grad_stepsGradient steps for beta update50

๐Ÿ”ง Implementation Details

Important: We modified the CLIP text encoder implementation to support an absorb token mechanism that replaces the class name token. This is critical for the VtT method to work correctly.

See /home/zzy/VLM_FSL/VtT/clip/model.py line 265 onwards for the implementation details.

Architecture Overview

The model consists of:

  1. CLIP backbone (ViT-B/16) for feature extraction
  2. LoRA adapters for efficient fine-tuning
  3. Mamba-based cross-modal bridge for vision-to-text alignment
  4. Absorb token mechanism in the text encoder

๐Ÿ“ Citation

If you find this work useful for your research, please cite:

@article{zhang2026reclaiming,
  title={Reclaiming Lost Text Layers for Source-Free Cross-Domain Few-Shot Learning},
  author={Zhang, Zhenyu and Chen, Guangyao and Zou, Yixiong and Li, Yuhua and Li, Ruixuan},
  journal={arXiv preprint arXiv:2603.05235},
  year={2026}
}

๐Ÿ™ Acknowledgments

This repository is developed based on:

We thank the authors for their excellent codebases.

๐Ÿ“„ License

This project is released under the MIT License.

๐Ÿ“ง Contact

For questions or issues, please open an issue on this repository or contact the authors.