claude_refactor_v3: Removed old conf with gins
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
# Balanced: GatedFusion with text captions enabled.
|
||||
# query = sigma(alpha) * drone + (1-sigma(alpha)) * text -> InfoNCE vs satellite
|
||||
|
||||
import src.datasets.visloc_with_captions
|
||||
import src.losses.multi_infonce
|
||||
import src.models.dual_encoder
|
||||
import src.training.train
|
||||
|
||||
# ---- Dual encoder ----
|
||||
DualEncoderCaptionTest.variant = "ViT-B-32"
|
||||
DualEncoderCaptionTest.pretrained_path = "checkpoints/RS5M_ViT-B-32.pt"
|
||||
DualEncoderCaptionTest.unfreeze_mode = "last_block"
|
||||
DualEncoderCaptionTest.embed_dim = 512
|
||||
DualEncoderCaptionTest.use_mlp_heads = False
|
||||
DualEncoderCaptionTest.baseline_mode = False
|
||||
DualEncoderCaptionTest.init_gate = 0.7
|
||||
DualEncoderCaptionTest.device = "cuda"
|
||||
|
||||
# ---- Fusion ----
|
||||
GatedFusion.init_gate = 0.7
|
||||
GatedFusion.baseline_mode = False
|
||||
|
||||
# ---- Loss ----
|
||||
InfoNCELoss.temperature_init = 0.1
|
||||
InfoNCELoss.temperature_final = 0.01
|
||||
InfoNCELoss.label_smoothing = 0.1
|
||||
InfoNCELoss.weight_q2g = 0.6
|
||||
InfoNCELoss.weight_g2q = 0.4
|
||||
|
||||
# ---- Dataset ----
|
||||
GeoLocCaptionDataset.drop_caption_prob = 0.0
|
||||
GeoLocCaptionDataset.seed = 42
|
||||
|
||||
# ---- Training ----
|
||||
TrainConfig.train_query_file = "/mnt/data1tb/cvgl_datasets/UAV-GeoLoc/Index/train_query.txt"
|
||||
TrainConfig.val_query_file = "/mnt/data1tb/cvgl_datasets/UAV-GeoLoc/Index/val_query.txt"
|
||||
TrainConfig.data_root = "/mnt/data1tb/cvgl_datasets/UAV-GeoLoc"
|
||||
TrainConfig.output_dir = "out/caption_test/balanced"
|
||||
TrainConfig.epochs = 10
|
||||
TrainConfig.batch_size = 128
|
||||
TrainConfig.num_workers = 4
|
||||
TrainConfig.learning_rate = 1e-4
|
||||
TrainConfig.weight_decay = 1e-4
|
||||
TrainConfig.grad_clip = 1.0
|
||||
TrainConfig.use_amp = True
|
||||
TrainConfig.eval_every = 2
|
||||
TrainConfig.seed = 42
|
||||
TrainConfig.device = "cuda"
|
||||
@@ -1,10 +0,0 @@
|
||||
# Baseline: no text fusion (gate forced to 1.0).
|
||||
# query = drone_only -> InfoNCE vs satellite
|
||||
# Reference R@1 for delta computation.
|
||||
|
||||
include 'balanced.gin'
|
||||
|
||||
DualEncoderCaptionTest.baseline_mode = True
|
||||
GatedFusion.baseline_mode = True
|
||||
|
||||
TrainConfig.output_dir = "out/caption_test/baseline_no_text"
|
||||
@@ -1,64 +0,0 @@
|
||||
# GTA-UAV Balanced: Asymmetric DINOv3 (WEB+SAT) with L1/L2/L3 captions.
|
||||
# Symmetric InfoNCE + MutuallyExclusiveSampler (no false negatives).
|
||||
# 10 epochs, MONA all 24 blocks, 1024-dim retrieval, hard negative bank.
|
||||
|
||||
import src.losses.multi_infonce
|
||||
|
||||
# ---- Training ----
|
||||
TrainConfigGTAUAV.epochs = 10
|
||||
TrainConfigGTAUAV.batch_size = 8
|
||||
TrainConfigGTAUAV.num_workers = 4
|
||||
TrainConfigGTAUAV.learning_rate = 1e-4
|
||||
TrainConfigGTAUAV.text_lr_factor = 0.1
|
||||
TrainConfigGTAUAV.weight_decay = 1e-4
|
||||
TrainConfigGTAUAV.grad_clip = 1.0
|
||||
TrainConfigGTAUAV.grad_accum_steps = 8
|
||||
TrainConfigGTAUAV.use_amp = True
|
||||
TrainConfigGTAUAV.eval_every = 1
|
||||
TrainConfigGTAUAV.warmup_epochs = 2
|
||||
TrainConfigGTAUAV.seed = 42
|
||||
TrainConfigGTAUAV.device = "cuda"
|
||||
|
||||
# ---- Model ----
|
||||
TrainConfigGTAUAV.init_gate = 0.7
|
||||
TrainConfigGTAUAV.baseline_mode = False
|
||||
TrainConfigGTAUAV.shared_encoder = True # single DINOv3 WEB for both branches
|
||||
TrainConfigGTAUAV.mona_bottleneck = 64
|
||||
TrainConfigGTAUAV.mona_last_n_blocks = 12 # inject MONA only in last 12/24 ViT blocks
|
||||
TrainConfigGTAUAV.gradient_checkpointing = True
|
||||
|
||||
# ---- Loss ----
|
||||
TrainConfigGTAUAV.loss_type = "symmetric"
|
||||
TrainConfigGTAUAV.tau_init = 0.07
|
||||
TrainConfigGTAUAV.label_smoothing = 0.1
|
||||
TrainConfigGTAUAV.learnable_temperature = True
|
||||
TrainConfigGTAUAV.weight_q2g = 0.6
|
||||
TrainConfigGTAUAV.weight_g2q = 0.4
|
||||
TrainConfigGTAUAV.neg_bank_size = 0 # 4096
|
||||
|
||||
# ---- Sampling ----
|
||||
TrainConfigGTAUAV.sampler_type = "mutex" # "dss" or "mutex"
|
||||
TrainConfigGTAUAV.dss_warmup_epochs = 1 # first N epochs use mutex-only (untrained embeds not useful)
|
||||
TrainConfigGTAUAV.dss_reembed_every = 1
|
||||
TrainConfigGTAUAV.use_mutex_sampler = True # legacy flag, kept True unless disabling both samplers
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text"
|
||||
|
||||
# ---- Tracking ----
|
||||
TrainConfigGTAUAV.use_wandb = False
|
||||
TrainConfigGTAUAV.use_tb = True
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
TrainConfigGTAUAV.gradcam_every = 5
|
||||
TrainConfigGTAUAV.use_profiler = False
|
||||
TrainConfigGTAUAV.log_grad_norms = True
|
||||
|
||||
# ---- InfoNCELoss (gin-configurable) ----
|
||||
InfoNCELoss.temperature_init = 0.07
|
||||
InfoNCELoss.learnable_temperature = True
|
||||
InfoNCELoss.label_smoothing = 0.1
|
||||
InfoNCELoss.weight_q2g = 0.6
|
||||
InfoNCELoss.weight_g2q = 0.4
|
||||
InfoNCELoss.tau_min = 0.01
|
||||
InfoNCELoss.tau_max = 0.1
|
||||
InfoNCELoss.hard_mining_k = 0 # 512 # 0 = use whole queue (disable mining)
|
||||
@@ -1,16 +0,0 @@
|
||||
# GTA-UAV Balanced (asymmetric, full MONA): WEB drone encoder + SAT satellite encoder.
|
||||
# MONA injected into all 24 ViT blocks of each encoder.
|
||||
# Same loss/sampling/optimizer as gtauav_balanced.gin; differs only in model arch.
|
||||
#
|
||||
# Trainable: ~17.6M (MONA 2× × 24 blocks + LoRA + TextFusionMLP + gates + tau)
|
||||
# Total params: ~733M (2× DINOv3-L + DGTRS-CLIP)
|
||||
# VRAM target (RTX 4090, 24 GB): ~16-20 GB at batch=8 with gradient checkpointing.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
# ---- Model overrides: asymmetric + full MONA ----
|
||||
TrainConfigGTAUAV.shared_encoder = False # WEB for drone, SAT for satellite
|
||||
TrainConfigGTAUAV.mona_last_n_blocks = 24 # MONA in all 24 ViT blocks (was 12)
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/balanced_asym"
|
||||
@@ -1,39 +0,0 @@
|
||||
# GTA-UAV Balanced (SOFIA-Tiny backbone): SOFIA v7.1 student trained from scratch
|
||||
# с двухуровневой text fusion:
|
||||
# 1. Mid-level: Text-FiLM в SAT и UAV heads (модулирует feature map перед GGeM/CHP).
|
||||
# 2. Late-level: GatedFusion на дескрипторах (как в DINOv3/StripNet вариантах).
|
||||
#
|
||||
# Trainable (~5-7M):
|
||||
# - SOFIA backbone (Tiny, ~5M, from scratch — нет pretrained)
|
||||
# - SOFIA heads (SatHead GGeM+BN+Linear, UAVHead AltitudeFiLM+CHP+BN+Linear, +Text-FiLM)
|
||||
# - DGTRS-CLIP LoRA (rank=4, ~147K)
|
||||
# - TextFusionMLP (3*768 -> 1024 -> 1024, ~3.4M, shared)
|
||||
# - Gates α_q, α_g + learnable τ
|
||||
#
|
||||
# Altitude (drone_height метры) подаётся в UAVHead.AltitudeFiLM из dataset meta CSV.
|
||||
# Для sat — altitude=None → FiLM passthrough (γ=1, β=0).
|
||||
#
|
||||
# Note: SOFIA from scratch — нужно больше эпох или warmup, чем frozen DINOv3/StripNet.
|
||||
# Mamba-2 backend (mamba_ssm) даёт 2-8x speedup vs torch fallback.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
# ---- Backbone ----
|
||||
TrainConfigGTAUAV.backbone = "sofia"
|
||||
TrainConfigGTAUAV.sofia_preset = "Tiny"
|
||||
TrainConfigGTAUAV.sofia_d_descriptor = 1024
|
||||
TrainConfigGTAUAV.sofia_use_text_film_uav = True
|
||||
TrainConfigGTAUAV.sofia_use_text_film_sat = True
|
||||
TrainConfigGTAUAV.sofia_lora_rank = 4
|
||||
# Mamba-1 used for Tiny (Mamba-2 torch fallback has a pre-existing reshape bug
|
||||
# with channels not divisible by default headdim; switch to "mamba2" for M/L
|
||||
# presets where channels % 64 == 0 OR install mamba_ssm CUDA kernels).
|
||||
TrainConfigGTAUAV.sofia_mamba_variant = "mamba1"
|
||||
TrainConfigGTAUAV.sofia_mamba_backend = "auto" # mamba_ssm if installed else torch fallback
|
||||
|
||||
# ---- Training overrides ----
|
||||
TrainConfigGTAUAV.gradient_checkpointing = False # SOFIA from-scratch — keep activations live
|
||||
TrainConfigGTAUAV.shared_encoder = True # ignored by SOFIA but kept for logging compat
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text_sofia"
|
||||
@@ -1,42 +0,0 @@
|
||||
# GTA-UAV Balanced (SOFIA v1 backbone): StripNet+DCNv4 hierarchical CNN
|
||||
# (~3-30M params depending on variant) trained from scratch с двухуровневой
|
||||
# text fusion:
|
||||
# 1. Mid-level: Text-FiLM в SAT и UAV heads (модулирует [B,C,8,8] перед GGeM).
|
||||
# 2. Late-level: GatedFusion на дескрипторах.
|
||||
#
|
||||
# UAV head: AltitudeFiLM(drone_height) + [TextFiLM] + GGeM + BN + Linear.
|
||||
# SAT head: [TextFiLM] + GGeM + BN + Linear.
|
||||
# Один backbone shared между sat/uav.
|
||||
#
|
||||
# Variant -> размер модели:
|
||||
# tiny_tiny: dims [16, 32, 80, 128] (~0.4M)
|
||||
# tiny : dims [32, 64, 128, 256] (~1M)
|
||||
# small : dims [64, 128, 320, 512] (~3M, default)
|
||||
# small_v2 : dims [64, 128, 256, 384] (~2M)
|
||||
#
|
||||
# Trainable (с small variant + text fusion):
|
||||
# - SOFIA v1 backbone (~3M) + heads (~0.6M)
|
||||
# - DGTRS-CLIP LoRA (rank=4, ~147K)
|
||||
# - TextFusionMLP (3*768 -> 1024 -> 1024, ~3.4M, shared)
|
||||
# - Gates α_q, α_g + learnable τ
|
||||
# Total trainable ~7M.
|
||||
#
|
||||
# Note: DCNv4 требует CUDA — обучение только на GPU. Не работает на CPU.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
# ---- Backbone ----
|
||||
TrainConfigGTAUAV.backbone = "sofia_v1"
|
||||
TrainConfigGTAUAV.sofia_v1_variant = "tiny"
|
||||
TrainConfigGTAUAV.sofia_v1_d_descriptor = 1024
|
||||
TrainConfigGTAUAV.sofia_v1_use_text_film_uav = True
|
||||
TrainConfigGTAUAV.sofia_v1_use_text_film_sat = True
|
||||
TrainConfigGTAUAV.sofia_v1_use_film_altitude = True
|
||||
TrainConfigGTAUAV.sofia_v1_lora_rank = 4
|
||||
|
||||
# ---- Training overrides ----
|
||||
TrainConfigGTAUAV.gradient_checkpointing = False # SOFIA v1 from-scratch
|
||||
TrainConfigGTAUAV.shared_encoder = True
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text_sofia_v1"
|
||||
@@ -1,27 +0,0 @@
|
||||
# GTA-UAV Balanced (StripNet backbone): StripNet-small + Conv-MONA in last 2 stages.
|
||||
# Replaces DINOv3 ViT-L/16 with strip-shaped DWConv hierarchical CNN (~28M params,
|
||||
# 10× smaller than DINOv3). Output 512-dim → projected to 1024 to match retrieval space.
|
||||
#
|
||||
# Trainable:
|
||||
# - Projection (Linear 512→1024): ~525K
|
||||
# - Conv-MONA in stages 3 & 4 (2 adapters per Block × 6 blocks total): ~2-3M
|
||||
# - LoRA on DGTRS-CLIP: 147K
|
||||
# - TextFusionMLP (shared): ~3.4M
|
||||
# - GatedFusion gates + tau: 3 scalars
|
||||
#
|
||||
# StripNet pretrained on ImageNet-1K (head dropped); state-dict naming follows
|
||||
# upstream Strip-R-CNN repo (`conv_spatial1/2`).
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
# ---- Backbone ----
|
||||
TrainConfigGTAUAV.backbone = "stripnet"
|
||||
TrainConfigGTAUAV.stripnet_path = "nn_models/STRIPNET/stripnet_s.pth"
|
||||
TrainConfigGTAUAV.stripnet_mona_last_n_stages = 2 # Conv-MONA in stages 3 & 4 (deepest)
|
||||
|
||||
# ---- Model overrides ----
|
||||
TrainConfigGTAUAV.shared_encoder = True # StripNet always shared (one CNN for both branches)
|
||||
TrainConfigGTAUAV.mona_bottleneck = 64 # Conv-MONA bottleneck channels
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text_stripnet"
|
||||
@@ -1,17 +0,0 @@
|
||||
# GTA-UAV Balanced (StripNet, fully unfrozen): all StripNet layers trainable.
|
||||
# Backbone trains with reduced LR (lr * stripnet_backbone_lr_factor).
|
||||
# Conv-MONA disabled by default — full fine-tune supplies enough capacity.
|
||||
# Set stripnet_mona_last_n_stages > 0 if you want MONA + fine-tune hybrid.
|
||||
#
|
||||
# Note: StripNet uses BatchNorm. With small batch (8) and gradient accumulation,
|
||||
# BN running stats may drift. Watch validation loss for instability.
|
||||
|
||||
include 'conf/gtauav_balanced_stripnet.gin'
|
||||
|
||||
# ---- Unfreeze backbone ----
|
||||
TrainConfigGTAUAV.stripnet_freeze = False
|
||||
TrainConfigGTAUAV.stripnet_mona_last_n_stages = 0 # disable Conv-MONA (full fine-tune handles adaptation)
|
||||
TrainConfigGTAUAV.stripnet_backbone_lr_factor = 0.1 # backbone lr = 1e-4 * 0.1 = 1e-5
|
||||
|
||||
# ---- Output ----
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/with_text_stripnet_unfrozen"
|
||||
@@ -1,28 +0,0 @@
|
||||
# GTA-UAV Baseline: no text fusion (gate forced to 1.0).
|
||||
# query = drone_only -> InfoNCE vs satellite
|
||||
# Reference R@1 for delta computation.
|
||||
#
|
||||
# Diagnostic mode (2026-04-24): DSS and hard-negative mining disabled after
|
||||
# the previous run collapsed (R@1 = 0.6% at epoch 8, train loss growing).
|
||||
# Hypothesis: DSS packs visually-identical drones at bs=8 and the hard-mining
|
||||
# queue amplifies that hardness — together they prevent convergence from a
|
||||
# nearly-random start. Run with mutex-only sampling and the full queue as
|
||||
# uniform negatives first, restore the extras incrementally once baseline
|
||||
# converges.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_inbatch"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
|
||||
# ---- Diagnostic overrides ----
|
||||
# Previous mutex-only run still collapsed at epoch 1 (val loss locked at log(8)).
|
||||
# Hypothesis refined: the MoCo-style queue stays stale because we have no
|
||||
# momentum encoder, and with reduced trainable surface (MONA-12) the model
|
||||
# can't reconcile fresh representations against 4096 stale negatives —
|
||||
# mode collapse. Disable the queue entirely so InfoNCE sees only the 8
|
||||
# fresh in-batch negatives, matching the OLD run's effective setup.
|
||||
TrainConfigGTAUAV.sampler_type = "mutex" # was "dss"
|
||||
TrainConfigGTAUAV.neg_bank_size = 0 # was 4096 — disable MoCo queue (no momentum encoder)
|
||||
InfoNCELoss.hard_mining_k = 0 # was 512 — irrelevant when queue is empty
|
||||
@@ -1,9 +0,0 @@
|
||||
# GTA-UAV Baseline (asymmetric, full MONA): no text fusion (gate forced to 1.0).
|
||||
# WEB drone encoder + SAT satellite encoder, MONA in all 24 ViT blocks.
|
||||
# Reference R@1 for delta computation against gtauav_balanced_asym.gin.
|
||||
|
||||
include 'conf/gtauav_balanced_asym.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_asym"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
@@ -1,13 +0,0 @@
|
||||
# GTA-UAV Baseline (SOFIA-Tiny backbone): no text fusion. Reference R@1 для
|
||||
# computing Δ R@1 vs gtauav_balanced_sofia.gin.
|
||||
#
|
||||
# В baseline_mode=True:
|
||||
# - Text-FiLM отключается (SOFIA heads работают только с altitude).
|
||||
# - DGTRS-CLIP не загружается, TextFusionMLP не строится.
|
||||
# - GatedFusion gates = 1.0 (text игнорируется).
|
||||
|
||||
include 'conf/gtauav_balanced_sofia.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_sofia"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
@@ -1,8 +0,0 @@
|
||||
# GTA-UAV Baseline (SOFIA v1 backbone): no text fusion. Reference R@1 для
|
||||
# computing Δ R@1 vs gtauav_balanced_sofia_v1.gin.
|
||||
|
||||
include 'conf/gtauav_balanced_sofia_v1.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_sofia_v1"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
@@ -1,8 +0,0 @@
|
||||
# GTA-UAV Baseline (StripNet backbone): no text fusion. Reference R@1 for
|
||||
# computing Δ R@1 against gtauav_balanced_stripnet.gin.
|
||||
|
||||
include 'conf/gtauav_balanced_stripnet.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_stripnet"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
@@ -1,8 +0,0 @@
|
||||
# GTA-UAV Baseline (StripNet, fully unfrozen): no text fusion. For Δ R@1
|
||||
# against gtauav_balanced_stripnet_unfrozen.gin.
|
||||
|
||||
include 'conf/gtauav_balanced_stripnet_unfrozen.gin'
|
||||
|
||||
TrainConfigGTAUAV.baseline_mode = True
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/baseline_stripnet_unfrozen"
|
||||
TrainConfigGTAUAV.use_gradcam = False
|
||||
@@ -1,8 +0,0 @@
|
||||
# GTA-UAV Image-heavy: gate initialized high (more image weight).
|
||||
# query = sigma(0.9) * drone + 0.1 * text
|
||||
# Minimal text contribution test.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
TrainConfigGTAUAV.init_gate = 0.9
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/image_heavy"
|
||||
@@ -1,8 +0,0 @@
|
||||
# GTA-UAV Text-heavy: gate initialized low (more text weight).
|
||||
# query = sigma(0.3) * drone + 0.7 * text
|
||||
# Stress test for text contribution.
|
||||
|
||||
include 'conf/gtauav_balanced.gin'
|
||||
|
||||
TrainConfigGTAUAV.init_gate = 0.3
|
||||
TrainConfigGTAUAV.output_dir = "out/gtauav/text_heavy"
|
||||
@@ -1,9 +0,0 @@
|
||||
# Text-heavy: gate initialized low (more text weight).
|
||||
# query = sigma(0.3) * drone + 0.7 * text
|
||||
|
||||
include 'balanced.gin'
|
||||
|
||||
DualEncoderCaptionTest.init_gate = 0.3
|
||||
GatedFusion.init_gate = 0.3
|
||||
|
||||
TrainConfig.output_dir = "out/caption_test/text_heavy"
|
||||
Reference in New Issue
Block a user