claude_refactor_v3: Updated main (entry point), trainer_new (last version of train_gtauav), check: is extracted evluate() from train to evaluator.py correct in new context

This commit is contained in:
pikaliov
2026-05-05 11:28:09 +03:00
parent 4e148a29bb
commit 248bd331d2
4 changed files with 1321 additions and 26 deletions

View File

@@ -3,13 +3,13 @@ from __future__ import annotations
"""Trainer for CVGL caption test on GTA-UAV-LR.
Decomposed from src/training/train_gtauav.py::train into a class with one
orchestrating method `run()` plus dedicated `_setup_*` / `_build_*` /
orchestrating method `train()` plus dedicated `_setup_*` / `_build_*` /
`_train_*` / `_evaluate_*` methods.
Lifecycle:
Trainer(...) → run() → done.
Trainer(...) → train() → done.
`run()` calls _build_* in dependency order, then _train_loop, then
`train()` calls _build_* in dependency order, then _train_loop, then
_final_evaluation; cleanup is in a `finally` block.
Currently supports DINOv3 and StripNet backbones only. SOFIA v1/v7.1 model
@@ -80,7 +80,7 @@ _SUPPORTED_BACKBONES: frozenset[str] = frozenset({"dinov3", "stripnet"})
def _build_param_groups(
model: nn.Module,
model: AsymmetricEncoder,
lr: float,
text_lr_factor: float,
stripnet_backbone_lr_factor: float = 0.1,
@@ -130,7 +130,7 @@ def _cosine_warmup_schedule(warmup_steps: int, total_steps: int):
def _embed_drone_queries(
model: nn.Module,
model: AsymmetricEncoder,
train_ds: GTAUAVDataset,
device: str,
batch_size: int,
@@ -155,7 +155,7 @@ def _embed_drone_queries(
)
all_embs: list[torch.Tensor] = []
with torch.inference_mode():
for batch in tqdm(loader, desc="dss-embed", unit="batch", leave=False):
for batch in tqdm(loader, desc=" dss-embed-queries", unit="batch", leave=False):
drone_img = batch["drone_img"].to(device, non_blocking=True)
altitude = batch.get("altitude")
if altitude is not None:
@@ -178,7 +178,7 @@ class Trainer:
All gin parameters arrive as 6 config objects; runtime state (model,
optimizer, loaders, ...) is built lazily by _build_* methods and lives
on `self`. `run()` calls them in dependency order.
on `self`. `train()` calls them in dependency order.
Backbones supported: 'dinov3', 'stripnet'.
"""
@@ -232,7 +232,7 @@ class Trainer:
# Public entry point
# ===================================================================
def run(self) -> None:
def train(self) -> None:
"""Full pipeline: setup → build → train → evaluate → cleanup."""
self._validate_backbone()
clear_vram()
@@ -1052,4 +1052,3 @@ class Trainer:
if self.tracker is not None:
self.tracker.close()