Skip to content

Add DINOv2 across detectors, selectable losses and bounded-memory feature heads - #6

Merged
yxteo2 merged 2 commits into
mainfrom
feat/dinov2-large-images
Sep 13, 2026
Merged

yxteo2 merged 2 commits into
mainfrom
feat/dinov2-large-images

Conversation

@yxteo2

@yxteo2 yxteo2 commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

The YAML builder previously limited backbone and detector combinations, preventing DINO experiments across the available pipelines. This PR adds frozen DINOv2 small/base features with patch-grid padding and extends the detector/loss selector.

  • FastFlow and SSN accept DINOv2 at 416, 512, 704 and rectangular input sizes, with optional channel projection and CUDA BF16 frozen extraction.
  • New experimental PaDiM and PatchCore variants fit normal training features once, without a training loss or optimizer. PaDiM streams CPU covariance statistics with an allocation guard; PatchCore uses a bounded CPU reservoir, greedy coreset and chunked nearest-neighbor distances.
  • A compact Dinomaly-style variant reconstructs frozen DINO patch features using a dropout MLP and checkpointed linear-attention decoder. Select cosine, MSE, Smooth L1 or weighted cosine–MSE. This is not the exact official Dinomaly implementation: original token handling, hard-mining hooks and optimizer/schedule are not reproduced. Differences and algorithm references are documented in docs/detector_choices.md.
  • SSN offers focal, weighted BCE, BCE–Dice and focal–Dice; FastFlow retains NLL. Invalid detector/loss combinations fail configuration validation.
  • Trainable detectors support sample-weighted gradient accumulation; all backbones stay frozen/eval. Evaluation drops optimizer states and reloads checkpoints on CPU.
  • Adds five DINO YAML profiles, shared metadata-based prediction, and a synthetic CUDA memory/fitting/training/reload smoke command. Statistical fitting uses deterministic training indices disjoint from calibration and test data.

Validation: 153 CPU tests passed, including real random-weight DINO small/base, all new losses, analytic PaDiM covariance, bounded/chunked PatchCore distances, 416/512/704 outputs, YAML train/fit–calibrate–test workflows and strict checkpoint reloads. Compileall, pyflakes and diff checks passed. Earlier in this PR, pretrained timm DINOv2-small also completed a 512-pixel CPU SSN training/reload smoke check.

Limits: no physical RTX 5070 Ti was available, so 16 GB fit and CUDA/BF16 execution require running the documented memory smoke command on the target card. Synthetic tests do not validate anomaly accuracy or saturate a large PatchCore reservoir. These experimental detector combinations do not claim published benchmark equivalence.

Main remains unchanged pending review and merge.

@yxteo2 yxteo2 changed the title Add frozen DINOv2, configurable losses and memory-aware large-image training Add DINOv2 across detectors, selectable losses and bounded-memory feature heads Sep 13, 2026
@yxteo2
yxteo2 merged commit b8e9f4e into main Sep 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant