This repository is the official implementation of "ChimeraLoRA: Multi-Head LoRA-Guided Synthetic Datasets" accepted by CVPR 2026.
ChimeraLoRA is a research project for synthetic dataset generation with few-shot guidance. It implements three methods:
- LoFT: Per-instance LoRA adapters fused together for image generation
- DataDream: Class-level or dataset-level LoRA finetuning for generation
- ChimeraLoRA: Shared LoRA-A matrix with per-instance LoRA-B matrices, enabling efficient multi-instance training
The pipeline has three stages: SD finetuning → Image generation → Classification training.
- sd-finetune/: Finetunes Stable Diffusion 2.1 with LoRA adapters on few-shot real images
- generation/: Uses finetuned LoRA weights to generate synthetic training images
- classification/: Trains CLIP or ResNet50 classifiers on synthetic data, evaluates on real test data
- LoFT (
main.py): Trains independent LoRA adapters per instance, fuses them at generation time via interpolation - DataDream (
main.py): Single LoRA adapter trained on all images (class-level or dataset-level) - ChimeraLoRA (
main_chimera.py): Factorized approach with shared LoRA-A matrix (captures common features) and per-instance LoRA-B matrices (captures instance-specific details). Outputs saved asB{i}_each/subdirectories containing individual adapters
Each folder has a local.yaml for machine-specific paths:
sd-finetune/local.yaml:output_dir,fewshot_dir,model_dir,mask_dirgeneration/local.yaml:save_dir,sd_lora_dir,model_dirclassification/local.yaml:output_dir,synth_train_data_dir,real_test_data_dir,metadata_dir,clip_download_root
Class names and templates are defined in sd-finetune/util.py (referenced by all stages):
CLASSNAMES: Dict mapping dataset names to class listsTEMPLATES_SMALL: Text prompt templates for generation
Supported datasets: imagenet, imagenet100, pets, eurosat, dtd, flowers102, cars, fgvc_aircraft, food101, caltech101, sun397
pip install -r requirements.txtcd sd-finetune
accelerate launch main.py \
--dataset=pets \
--target_class_idx=0 \
--instance_idx=0 \
--n_shot=4 \
--fewshot_seed=seed0 \
--num_train_epochs=600 \
--rank=4 \
--learning_rate=1e-3cd sd-finetune
# Class-level: set target_class_idx, leave instance_idx=None
# Dataset-level: set both to None
accelerate launch main.py \
--dataset=pets \
--target_class_idx=0 \
--n_shot=16 \
--num_train_epochs=200 \
--rank=16 \
--train_text_encoder=Truecd sd-finetune
accelerate launch main_chimera.py \
--dataset=pets \
--n_shot=4 \
--fewshot_seed=seed0 \
--num_train_epochs=400 \
--rank=16 \
--learning_rate_A=1e-4 \
--learning_rate_B=1e-3 \
--method=JOINT \
--train_text_encoder=Truecd generation
# LoFT generation
python main.py \
--dataset=pets \
--method=loft \
--n_shot=4 \
--fewshot_seed=seed0 \
--loft_interpolation_weight=0.5 \
--n_image_per_class=500 \
--bs=5
# ChimeraLoRA generation (uses Dirichlet sampling over B adapters)
python main.py \
--dataset=pets \
--method=chimera_dir \
--n_shot=4 \
--fewshot_seed=seed0 \
--n_image_per_class=500 \
--bs=5cd classification
python main.py \
--method=loft \
--loft_interpolation_weight=0.5 \
--dataset=pets \
--n_img_per_cls=100 \
--n_shot=4 \
--model_type=clip \
--epochs=60 \
--lr=1e-4 \
--batch_size_per_gpu=256method=loft: Uses per-instance LoRA fusion withloft_interpolation_weight(0.5 = equal blend of 2 LoRAs)method=datadream-cls: Class-level LoRAmethod=datadream-dset: Dataset-level LoRAmethod=chimera/method=chimera_dir: ChimeraLoRA with Dirichlet-sampled weights for generation
n_shot: Number of real images per class (commonly 1, 4, 16)fewshot_seed: Data split seed (e.g., "seed0")
rank: LoRA rank (LoFT uses 4, DataDream uses 16, ChimeraLoRA uses 4-16)target_class_idx: Class index for class-level training (None = dataset-level)instance_idx: Instance index for LoFT (None = not LoFT method)
learning_rate_A: Learning rate for shared A matrix (typically 1e-4)learning_rate_B: Learning rate for per-instance B matrices (typically 1e-3)method: Training mode -JOINT(train A+B together) orALT(alternating optimization)step: Number of steps between alternating A/B updates (for ALT mode)
Few-shot real images should be organized as:
$FEWSHOT_DIR/$DATASET/shot{N}_seed{S}/$CLASS_NAME/*.jpg
Generated synthetic images are saved to:
$SAVE_DIR/$DATASET/{method}_avg_{params}/shot{N}_{seed}/$CLASS_NAME/*.png
clip: CLIP ViT-B/16 with LoRA finetuning (default)resnet50: ResNet50 trained from scratch