Skip to content

Latest commit

 

History

History
110 lines (97 loc) · 8.42 KB

protocol.md

File metadata and controls

110 lines (97 loc) · 8.42 KB

Comparison protocol

Question

Does LeJEPA pre-training of a lightweight encoder, on unlabelled frames of both target domains (NYU raw and KITTI raw together), improve monocular depth estimation over random initialisation, when the encoder is then frozen and only the decoder is trained on each dataset?

Protocol as agreed with Claudio Schiavella (email of 28/11 + messages of 28/11 evening): one joint pre-training per model and variant, 1 seed for now, zero-shot evaluation on unseen datasets later.

Models

Model Encoder Decoder Pyramid (channels, finest to deepest) Native output
FlexDepth-Nano YOLO11-N, 1.37 M 0.16 M 16 / 64 / 128 / 128 / 256 sigmoid disparity (4 scales)
ZipDepth-Base QARep CNN, 6.63 M (unfused) 0.15 M 24 / 48 / 96 / 192 / 384 affine-invariant inverse depth (ReLU)
BoRe-Depth MPViT-Tiny, 5.63 M 3.04 M 64 / 96 / 176 / 216 / 216 depth = 1 / (10 sigmoid + 0.01)
METER (xxs / xs / s) MobileViT, 0.64 / 1.20 / 2.99 M 0.08 / 0.25 / 0.30 M 5 levels metric depth (1/4 resolution)

Numbers measured on the pinned commits (tests/test_baselines.py). Decoders differ by about 20x, so LeJEPA gains are compared within each model, not across models.

Steps (per model)

  1. Public weights, evaluated on the test sets without retraining (FlexDepth on NYU: retrained by us).
  2. LeJEPA pre-training of the encoder on the deepest map (stride 32), once per model and variant on NYU raw and KITTI raw together (decided 28/11, replaces "one pre-training per dataset"), with test and validation scenes / drives of both datasets excluded and balanced sampling (see Joint pre-training data):
    • classic: official recipe, configs/lejepa/classic.yaml;
    • dense: METER recipe (lambda 0.02, lr 5e-3, 4x4 grid), configs/lejepa/dense.yaml;
    • classic_phase1.yaml / dense_phase1.yaml reproduce the course-project code exactly: same views, loss and gradients for the same seed (scripts/verify_phase1_equivalence.py). The protocol dense differs from dense_phase1 only in drawing crops and colour augmentation per image (phase 1 drew one set of parameters for the whole batch).
  3. Frozen encoder, decoder-only training, identical procedure for the three initialisations (random, LeJEPA classic, LeJEPA dense), separately on NYU and on KITTI, 1 seed for now (training/trainer.py, task: finetune). The same jointly pre-trained encoder is used for both datasets.
    • Loss (decided 28/11): the original loss of each model. FlexDepth and BoRe-Depth: photometric self-supervised loss on frame triplets (training/photometric.py, loss: photometric). ZipDepth: its own ZipDepthLoss (SSI after median/MAD normalisation + 4-scale gradient matching, weights 1 / 2) on Depth Anything V2 Large pseudo-depth, as in its original distillation (loss: zipdepth; targets from scripts/make_pseudo_depth.py, on the middle frames of the same triplet lists). Ground-truth silog is implemented as a reference only.
    • ZipDepth's output is affine-invariant inverse depth: its validation uses scale-and-shift, and its test numbers are read after scale-and-shift (median scaling is reported but not meaningful).
    • Ablation (30/11): unfrozen encoder. The same 18 runs again with freeze_encoder: false: the encoder is trained together with the decoder, in one parameter group with the same learning rate as the decoder, BatchNorm in train mode; everything else (loss, data, schedule, epochs, seed, random-arm BatchNorm re-estimation before training) as in the frozen runs. It shows whether the LeJEPA gain survives when the encoder can adapt.

Totals (1 seed): 6 pre-trainings (3 models x 2 variants, each on NYU + KITTI), 18 decoder trainings with a frozen encoder (3 models x 3 initialisations x 2 datasets) and 18 with the encoder unfrozen (ablation), i.e. 42 training runs, each decoder evaluated on the test set of its dataset; plus FlexDepth on NYU and the public-weight evaluation (done). More seeds only if the results and the GPU budget call for them (Claudio, 28/11: "for now 1").

  1. Later: zero-shot evaluation on a dataset never seen in pre-training or fine-tuning (Claudio, 28/11: "maybe later"). Candidates: SUN RGB-D, DIODE, Virtual KITTI 2. Which checkpoints and which split: to define when the main results are in.

Joint pre-training data (dataset: joint, configs/runs/example_pretrain_joint.yaml)

  • Every batch holds the same number of NYU and KITTI frames, so neither dataset dominates (Claudio: balanced sampling; Luca: half-half batches). Frames come from nyu_raw_frames_stride10.txt and kitti_raw_frames.txt (KITTI train drives), both checked by check_list (no test or validation scene / drive).
  • Same input size and shape for both datasets (Luca's proposal, 29/11): NYU unchanged, the whole 4:3 frame resized to the pre-training size (e.g. 288 x 384); KITTI: a random 4:3 crop first (375 x 500 out of 375 x 1242, a new position every time), then the same resize as NYU. The LeJEPA views are drawn from that image, as today. No distortion, NYU keeps its full field of view, KITTI loses horizontal context (an accepted limit, also in Depth Anything).
  • This is the Depth Anything V2 recipe (sota/depth_anything_v2/metric_depth/dataset/: resize keeping the aspect ratio until the shorter side reaches the crop size, then a random crop) with a 4:3 crop instead of a square one, so that NYU is not cropped. Depth Anything trains one dataset at a time, so the per-batch balancing is ours.
  • Implementation: data.datasets.JointFrames (sources + random_aspect_crop) and training.trainer.BalancedEpochSampler. An epoch has ceil(max(sizes) / (batch_size / 2)) batches: the larger list is seen once, the smaller one is reshuffled and cycled, so both contribute the same number of frames; deterministic per (seed, epoch) and resumable mid-epoch. batch_size must be even.

Splits (lists in <data root>/splits/, generated on the lab)

Dataset Train (raw triplets) Validation Test
NYU Depth V2 24,863 ~5% of the non-test raw scenes (hash of the scene id) 654 labelled frames
KITTI 27,154 (109 drives) 14 drives (hash of the drive name): 1,595 triplets, 1,483 annotated frames 652 Eigen pairs (28 drives, excluded entirely)

data.datasets.check_list rejects train lists that touch a test or validation scene / drive; on 28/11 the KITTI lists were also checked on every path of every line.

Fairness rules

  • Same test sets (NYU 654, KITTI 652 annotated), same crops (Eigen / Garg) and depth caps (10 m / 80 m).
  • Metrics after median scaling and after scale-and-shift (on inverse depth): evaluation/metrics.py.
  • 1 seed for now (same seed for every arm); mean and standard deviation if more seeds are added. Same training budget for every arm.
  • Frozen encoder always in eval mode (DepthBaseline.freeze_encoder()), so BatchNorm statistics never change. Unfrozen ablation: encoder in train mode, same optimiser, learning rate and schedule as the decoder.
  • Random arm: BatchNorm statistics re-estimated before freezing on the same balanced NYU + KITTI frames used by LeJEPA (decided 29/11: bn_lists = the pre-training train_lists, bn_image_size = its image_size, same 4:3 KITTI crop), for both the NYU and the KITTI fine-tuning, so the three arms differ only in the weights.

Numerics

  • Pascal GPUs train in fp32, newer GPUs in fp16 autocast, never bf16 (SIGReg diverged in bf16 in phase 1): utils/device.py.
  • SIGReg is not compatible with gradient accumulation: the batch is what fits on the GPU.

Known pitfalls of the original code (handled here)

  • FlexDepth ignores --seed (init_seeds(1 + rank) is hard-coded) and its --freeze_encoder leaves BatchNorm in train mode: we only import its architecture.
  • ZipDepth: cross_scale.low_to_high (18,432 parameters) is not reached from the deepest map, so it is trained with the decoder (DDP would need find_unused_parameters).
  • BoRe-Depth: its MPViT train() returns None (never chain .eval()); mmcv is replaced by plain PyTorch for norm layers and checkpoint loading; its public weights must be loaded with strict key checking (the original code uses strict=False).
  • METER needs view sizes divisible by 32 (phase 1 used 256 / 128 px views).