justdata 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. justdata-1.1.0/PKG-INFO +1130 -0
  2. justdata-1.1.0/README.md +1087 -0
  3. {justdata-1.0.0 → justdata-1.1.0}/pyproject.toml +5 -2
  4. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/__init__.py +1 -1
  5. justdata-1.1.0/src/justdata/acoustic/_dcase.py +23 -0
  6. justdata-1.1.0/src/justdata/acoustic/_manifests.py +31 -0
  7. justdata-1.1.0/src/justdata/acoustic/_random.py +54 -0
  8. justdata-1.1.0/src/justdata/acoustic/_signal.py +79 -0
  9. justdata-1.1.0/src/justdata/acoustic/augment/_common.py +70 -0
  10. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/batch.py +10 -83
  11. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/patchout.py +26 -7
  12. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/spectrogram.py +12 -92
  13. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/waveform.py +13 -138
  14. justdata-1.1.0/src/justdata/acoustic/batching.py +11 -0
  15. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/ast.py +1 -12
  16. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/ced.py +2 -9
  17. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/efficientat.py +2 -22
  18. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/passt.py +2 -9
  19. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/noise.py +2 -32
  20. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/registry.py +4 -42
  21. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/dcase2025.py +9 -45
  22. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/ast.py +0 -4
  23. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/mel.py +1 -14
  24. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/segment.py +1 -12
  25. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/sources.py +20 -63
  26. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/tasks.py +52 -24
  27. justdata-1.1.0/src/justdata/core/finalization.py +265 -0
  28. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/loader.py +127 -29
  29. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/metadata.py +7 -2
  30. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/sources.py +37 -0
  31. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/stats.py +2 -1
  32. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/auto.py +10 -39
  33. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/color.py +7 -2
  34. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/geometric.py +83 -3
  35. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/mixing.py +38 -4
  36. justdata-1.1.0/src/justdata/vision/corruptions/__init__.py +27 -0
  37. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/corruptions/blur.py +38 -1
  38. justdata-1.1.0/src/justdata/vision/corruptions/digital.py +52 -0
  39. justdata-1.1.0/src/justdata/vision/corruptions/noise.py +44 -0
  40. justdata-1.1.0/src/justdata/vision/corruptions/registry.py +471 -0
  41. justdata-1.1.0/src/justdata/vision/corruptions/standard.py +331 -0
  42. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/corruptions/weather.py +47 -1
  43. justdata-1.1.0/src/justdata/vision/minic.py +137 -0
  44. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/presets.py +36 -64
  45. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/sources.py +233 -3
  46. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/stages.py +4 -1
  47. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/tasks/classification.py +43 -14
  48. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/utils.py +24 -151
  49. justdata-1.0.0/PKG-INFO +0 -860
  50. justdata-1.0.0/README.md +0 -817
  51. justdata-1.0.0/src/justdata/acoustic/batching.py +0 -27
  52. justdata-1.0.0/src/justdata/core/finalization.py +0 -173
  53. justdata-1.0.0/src/justdata/vision/corruptions/__init__.py +0 -16
  54. justdata-1.0.0/src/justdata/vision/corruptions/digital.py +0 -26
  55. justdata-1.0.0/src/justdata/vision/corruptions/noise.py +0 -20
  56. justdata-1.0.0/src/justdata/vision/corruptions/registry.py +0 -113
  57. justdata-1.0.0/src/justdata/vision/minic.py +0 -69
  58. {justdata-1.0.0 → justdata-1.1.0}/LICENSE +0 -0
  59. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/__init__.py +0 -0
  60. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/adapters.py +0 -0
  61. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/__init__.py +0 -0
  62. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/augment/configs.py +0 -0
  63. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/channel.py +0 -0
  64. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/__init__.py +0 -0
  65. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/compat/panns.py +0 -0
  66. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/configs.py +0 -0
  67. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/__init__.py +0 -0
  68. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/codec.py +0 -0
  69. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/datasets.py +0 -0
  70. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/device.py +0 -0
  71. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/dynamics.py +0 -0
  72. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/filters.py +0 -0
  73. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/reverb.py +0 -0
  74. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/corruptions/timefreq.py +0 -0
  75. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/datasets.py +0 -0
  76. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/decoding.py +0 -0
  77. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/eval_views.py +0 -0
  78. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/evals.py +0 -0
  79. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/filters.py +0 -0
  80. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/__init__.py +0 -0
  81. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/kaldi.py +0 -0
  82. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/log.py +0 -0
  83. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/mfcc.py +0 -0
  84. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/pcen.py +0 -0
  85. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/frontends/stft.py +0 -0
  86. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/jax.py +0 -0
  87. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/labels.py +0 -0
  88. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/layouts.py +0 -0
  89. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/metadata.py +0 -0
  90. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/normalization.py +0 -0
  91. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/pipelines.py +0 -0
  92. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/postprocessing.py +0 -0
  93. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/preprocessing.py +0 -0
  94. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/presets.py +0 -0
  95. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/registry.py +0 -0
  96. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/resampling.py +0 -0
  97. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/schema.py +0 -0
  98. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/stages.py +0 -0
  99. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/acoustic/stats.py +0 -0
  100. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/audio/__init__.py +0 -0
  101. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/__init__.py +0 -0
  102. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/adapters.py +0 -0
  103. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/augmentations.py +0 -0
  104. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/filters.py +0 -0
  105. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/label_mixing.py +0 -0
  106. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/presets.py +0 -0
  107. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/core/registry.py +0 -0
  108. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/corruptions.py +0 -0
  109. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/py.typed +0 -0
  110. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/__init__.py +0 -0
  111. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/__init__.py +0 -0
  112. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/composed.py +0 -0
  113. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/augmentations/registry.py +0 -0
  114. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/datasets.py +0 -0
  115. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/encodings/__init__.py +0 -0
  116. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/encodings/heatmaps.py +0 -0
  117. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/pipelines.py +0 -0
  118. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/tasks/__init__.py +0 -0
  119. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/tasks/depth.py +0 -0
  120. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/tasks/segmentation.py +0 -0
  121. {justdata-1.0.0 → justdata-1.1.0}/src/justdata/vision/transforms.py +0 -0
@@ -0,0 +1,1130 @@
1
+ Metadata-Version: 2.4
2
+ Name: justdata
3
+ Version: 1.1.0
4
+ Summary: A TensorFlow-native data pipeline library with a modality-neutral core and first-class computer vision and acoustic recipes
5
+ Author: clementpoiret
6
+ Author-email: clementpoiret <clement@linux.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: loguru>=0.7.3
10
+ Requires-Dist: tensorflow>=2.18.1
11
+ Requires-Dist: tensorflow-datasets>=4.9.9
12
+ Requires-Dist: datasets[audio]>=4.5.0 ; extra == 'acoustic'
13
+ Requires-Dist: soundfile>=0.12 ; extra == 'acoustic'
14
+ Requires-Dist: soxr>=0.5 ; extra == 'acoustic'
15
+ Requires-Dist: librosa>=0.11 ; extra == 'acoustic'
16
+ Requires-Dist: torch==2.10.0 ; extra == 'acoustic'
17
+ Requires-Dist: torchcodec==0.10.0 ; extra == 'acoustic'
18
+ Requires-Dist: datasets[audio]>=4.5.0 ; extra == 'dev'
19
+ Requires-Dist: datasets[vision]>=4.5.0 ; extra == 'dev'
20
+ Requires-Dist: filelock>=3.20 ; extra == 'dev'
21
+ Requires-Dist: librosa>=0.11 ; extra == 'dev'
22
+ Requires-Dist: matplotlib>=3.10.8 ; extra == 'dev'
23
+ Requires-Dist: pillow>=12.2.0 ; extra == 'dev'
24
+ Requires-Dist: pytest>=9.0.2 ; extra == 'dev'
25
+ Requires-Dist: ruff==0.15.20 ; extra == 'dev'
26
+ Requires-Dist: soundfile>=0.12 ; extra == 'dev'
27
+ Requires-Dist: soxr>=0.5 ; extra == 'dev'
28
+ Requires-Dist: torch==2.10.0 ; extra == 'dev'
29
+ Requires-Dist: torchcodec==0.10.0 ; extra == 'dev'
30
+ Requires-Dist: torchaudio==2.10.0 ; extra == 'golden'
31
+ Requires-Dist: torchlibrosa==0.1.0 ; extra == 'golden'
32
+ Requires-Dist: datasets[vision]>=4.5.0 ; extra == 'vision'
33
+ Requires-Dist: filelock>=3.20 ; extra == 'vision'
34
+ Requires-Dist: pillow>=12.2.0 ; extra == 'vision'
35
+ Requires-Dist: wilds>=2.0.0 ; extra == 'wilds'
36
+ Requires-Python: >=3.11, <3.14
37
+ Provides-Extra: acoustic
38
+ Provides-Extra: dev
39
+ Provides-Extra: golden
40
+ Provides-Extra: vision
41
+ Provides-Extra: wilds
42
+ Description-Content-Type: text/markdown
43
+
44
+ # justdata
45
+
46
+ A TensorFlow-native data pipeline library with a modality-neutral core and first-class computer vision and acoustic
47
+ recipes. `justdata.core` owns loading, adapter, preset, metadata, padding, and seeded execution machinery;
48
+ `justdata.vision` owns image schemas, transforms, augmentations, corruptions, tasks, and vision presets.
49
+ `justdata.acoustic` owns audio schemas, decoding, resampling, segmentation, frontends, augmentations, corruptions, DCASE
50
+ helpers, stats, metadata/JAX helpers, and acoustic presets.
51
+
52
+ ______________________________________________________________________
53
+
54
+ ## Table of Contents
55
+
56
+ 1. [Installation](#installation)
57
+ 1. [Architecture](#architecture)
58
+ 1. [Data Pipeline Stages](#data-pipeline-stages)
59
+ 1. [Supervised Learning — Training Pipelines](#supervised-learning--training-pipelines)
60
+ 1. [Automatic Augmentation Policies: RandAugment, TrivialAugment, and TrivialAugmentWide](#automatic-augmentation-policies-randaugment-trivialaugment-and-trivialaugmentwide)
61
+ 1. [Supervised Learning — Validation Pipelines](#supervised-learning--validation-pipelines)
62
+ 1. [The `timm` ImageNet Recipes (ResNet Strikes Back: A1/A2/A3)](#the-timm-imagenet-recipes-resnet-strikes-back-a1a2a3)
63
+ 1. [Self-Supervised Learning Pipeline (DINOv2)](#self-supervised-learning-pipeline-dinov2)
64
+ 1. [Registry System](#registry-system)
65
+ 1. [Presets and Smart Merging](#presets-and-smart-merging)
66
+ 1. [Acoustic Pipelines](#acoustic-pipelines)
67
+ 1. [Dataset Adapters](#dataset-adapters)
68
+ 1. [Mini-C Corruption Benchmark](#mini-c-corruption-benchmark)
69
+ 1. [Audio Corruption Benchmark](#audio-corruption-benchmark)
70
+ 1. [Usage](#usage)
71
+ 1. [Development](#development)
72
+
73
+ ______________________________________________________________________
74
+
75
+ ## Installation
76
+
77
+ ```bash
78
+ pip install justdata
79
+ ```
80
+
81
+ **Requirements:** Python 3.11–3.13, TensorFlow ≥ 2.18.1, TensorFlow Datasets ≥ 4.9.9. Install optional modality extras
82
+ with `justdata[vision]` for Hugging Face vision datasets, `justdata[wilds]` for WILDS image classification datasets, or
83
+ `justdata[acoustic]` for audio dataset/source dependencies.
84
+
85
+ ______________________________________________________________________
86
+
87
+ ## Architecture
88
+
89
+ `justdata` is structured around a fixed, four-stage pipeline abstraction. The currently supported vision tasks,
90
+ classification and segmentation, each expose exactly four composable functions. Object detection and depth estimation
91
+ are future scope and are not registered capabilities.
92
+
93
+ ```
94
+ (preprocess_fn, augment_fn, late_augment_fn, postprocess_fn)
95
+ ```
96
+
97
+ These are assembled by `justdata.core.load_ds` into the following execution graph:
98
+
99
+ ```
100
+ fetch_ds -> adapter -> preprocess -> cache -> augment -> shuffle -> postprocess -> batch -> late_augment -> pad -> prefetch
101
+ ```
102
+
103
+ The strict ordering reflects the execution domain requirements articulated throughout this document: format
104
+ normalization occurs before the optional preprocessing cache; spatial and photometric distortions precede tensor
105
+ conversion and normalization; and batch-level operations (Mixup, CutMix, random erasing) occur after batching on the
106
+ GPU. An optional model-input cache can be inserted after deterministic postprocessing and before batching; for training
107
+ it must be explicitly opted in and is placed before shuffle so epoch order is not frozen.
108
+
109
+ ### TensorFlow execution controls
110
+
111
+ `load_ds` uses `tf.data.AUTOTUNE` for loader-owned maps by default. Advanced callers may set
112
+ `map_parallel_calls`, `private_threadpool_size`, and `max_intra_op_parallelism` to bound TensorFlow input-pipeline
113
+ concurrency. Omitting these arguments preserves the default TensorFlow behavior.
114
+ The map limit also applies to metadata sidecar writing when enabled.
115
+
116
+ ### Core Public API
117
+
118
+ | Function | Description |
119
+ | :-------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- |
120
+ | `justdata.core.fetch_ds(dataset_names, splits_info, data_dir)` | Raw dataset loading through registered source loaders. Returns a `tf.data.Dataset` in canonical schema. |
121
+ | `justdata.core.load_ds(...)` | Full pipeline for training or evaluation. Handles caching, augmentation, shuffling, batching, and prefetching. |
122
+ | `justdata.vision.minic.create_minic_datasets(...)` | Constructs Mini-C corruption benchmark datasets from a shared preprocessed base dataset. |
123
+ | `justdata.acoustic.corruptions.create_audio_corruption_datasets(...)` | Constructs acoustic corruption benchmark datasets from a shared preprocessed base dataset. |
124
+ | `justdata.acoustic.dcase2025.make_source_dataset(...)` | Builds DCASE Task 1 source-domain datasets with split-safety checks. |
125
+
126
+ Import `justdata.vision` before resolving built-in vision datasets or pipelines. Hugging Face vision datasets are
127
+ referenced with the `hf:` prefix (e.g., `hf:cifar10`), and WILDS image classification datasets are referenced with the
128
+ `wilds:` prefix (e.g., `wilds:camelyon17`).
129
+
130
+ ______________________________________________________________________
131
+
132
+ ## Data Pipeline Stages
133
+
134
+ ### Stage 1: Preprocessing (before cache)
135
+
136
+ Format normalization is performed before the optional decoded-dataset cache. Operations include rank fixing (2D -> 3D),
137
+ CHW -> HWC transposition, grayscale -> RGB expansion, and RGBA -> RGB projection. The output shape is forced to
138
+ `[None, None, 3]`.
139
+
140
+ ### Stage 2: Augmentation (per-sample, training only)
141
+
142
+ Per-sample spatial and photometric augmentations are applied after the optional cache stage, ensuring that each training
143
+ epoch receives independently sampled augmentations. All augmentation functions use `tf.random.split` for stateless
144
+ randomization, enabling full reproducibility.
145
+
146
+ ### Stage 3: Postprocessing (every sample)
147
+
148
+ Resize, channel-wise normalization to zero mean and unit standard deviation, and optional HWC -> CHW transposition. This
149
+ stage runs unconditionally for both training and evaluation.
150
+
151
+ Set `cache_model_inputs=True` with `model_input_cache_path` to cache these resized, normalized tensors on local SSD. For
152
+ `dataset_type="train"`, also set `allow_train_model_input_cache=True` and use it only when the training view is
153
+ deterministic; stochastic crops or photometric augmentation will be materialized into the cache on first fill.
154
+
155
+ ### Stage 4: Late Augmentation (per-batch, training only)
156
+
157
+ Batch-level operations—Mixup, CutMix, and random erasing—are applied after batching. These operations are strictly
158
+ training-only and require a formed batch to operate across the sample dimension.
159
+
160
+ ______________________________________________________________________
161
+
162
+ ## Supervised Learning — Training Pipelines
163
+
164
+ To ensure mathematical correctness, the training pipeline is strictly segregated by execution domain. Spatial and
165
+ photometric distortions are applied to `[0, 255]` image tensors (PIL-equivalent domain) before zero-mean tensor
166
+ normalization.
167
+
168
+ ### 1. Image Domain Augmentations
169
+
170
+ #### Geometric Augmentations
171
+
172
+ - **CIFAR-10/100:** `RandomCrop(32, padding=4, padding_mode='zeros')` -> `RandomHorizontalFlip(p=0.5)`.
173
+ - **ImageNet-1K:** `RandomResizedCrop(size=224)` (or **256**). Scale: **(0.08, 1.0)**, Aspect ratio: **(0.75, 1.33)**,
174
+ Interpolation: Bicubic. -> `RandomHorizontalFlip(p=0.5)`.
175
+
176
+ #### Photometric Augmentations (Mutually Exclusive Branches)
177
+
178
+ The photometric augmentation strategy is architecture-dependent and the two branches are mutually exclusive.
179
+
180
+ - **Modern Branch (ViT / ConvNeXt):** Apply `RandAugment(num_ops=2, magnitude=9)`, `TrivialAugment`, or
181
+ `TrivialAugmentWide` (see the
182
+ [Automatic Augmentation Policies](#automatic-augmentation-policies-randaugment-trivialaugment-and-trivialaugmentwide)
183
+ section for full specifications). Color Jitter is explicitly disabled to prevent redundant and destructive color space
184
+ distortion.
185
+ - **Legacy Branch (ResNet):** Apply `ColorJitter(brightness=0.4, contrast=0.4, saturation=0.4, hue=0.1)`. RandAugment is
186
+ disabled.
187
+
188
+ ### 2. Tensor Domain
189
+
190
+ - **Conversion & Scaling:** `ToImage()` -> `ToDtype(float32, scale=True)`. Maps **[0, 255]** -> **[0.0, 1.0]**.
191
+ - **Normalization:**
192
+ - **CIFAR-10:** `mean=(0.4914, 0.4822, 0.4465)`, `std=(0.2023, 0.1994, 0.2010)`
193
+ - **CIFAR-100:** `mean=(0.5071, 0.4867, 0.4408)`, `std=(0.2675, 0.2565, 0.2761)`
194
+ - **ImageNet-1K:** `mean=(0.485, 0.456, 0.406)`, `std=(0.229, 0.224, 0.225)`
195
+ - **Random Erasing (Cutout):** Applied to the normalized tensor. `p=0.25`, `scale=(0.02, 0.33)`, `ratio=(0.3, 3.3)`.
196
+
197
+ ### 3. Mini-Batch Domain
198
+
199
+ Applied across the batch dimension during training.
200
+
201
+ - **Repeated Augmentation (RA):** Enabled for ViTs. Typically **3** repetitions per sample per mini-batch.
202
+ - **Mixup & CutMix:** Controlled by `mixup_prob=1.0` (probability of batch mixing) and `switch_prob=0.5` (probability of
203
+ selecting CutMix over Mixup).
204
+ - **Mixup:** $\tilde{x} = \lambda x_i + (1 - \lambda) x_j$, where $\lambda \sim \mathrm{Beta}(0.8,, 0.8)$.
205
+ - **CutMix:** Replaces a rectangular bounding box region; $\lambda \sim \mathrm{Beta}(1.0,, 1.0)$.
206
+ - *Note: The $\alpha$ values (0.8 and 1.0) reflect the DeiT baseline. Mixup/CutMix parameters are strictly
207
+ recipe-dependent; see the A1/A2/A3 section for ResNet-specific variations.*
208
+ - **Label Smoothing:** Cross-entropy loss modification with $\varepsilon = 0.1$.
209
+
210
+ ______________________________________________________________________
211
+
212
+ ## Automatic Augmentation Policies: RandAugment, TrivialAugment, and TrivialAugmentWide
213
+
214
+ `justdata` provides native TensorFlow implementations of three closely related automatic augmentation policies:
215
+ **RandAugment** (Cubuk et al., 2020), **TrivialAugment** (Müller & Hutter, 2021), and **TrivialAugmentWide** (Müller &
216
+ Hutter, 2021). All three are registered under the `augment_strategy` registry and share a common operation pool and
217
+ magnitude discretization framework.
218
+
219
+ ### 1. Pipeline Position and Domain Constraints
220
+
221
+ To guarantee deterministic reproduction of published results, all three policies are applied exclusively in the **image
222
+ domain** (integer `uint8` tensors, pixel values $\in [0, 255]$), before tensor conversion to floating-point and
223
+ channel-wise normalization. The canonical execution order within the per-sample augmentation stage is:
224
+
225
+ 1. Random Resized Crop (or Random Pad Crop for CIFAR)
226
+ 1. **RandAugment / TrivialAugment / TrivialAugmentWide**
227
+ 1. Random Horizontal Flip *(integrated into the crop strategy)*
228
+ 1. `ToTensor` — scales to float $[0.0, 1.0]$ *(postprocessing stage)*
229
+ 1. `Normalize` — subtracts dataset mean, divides by standard deviation *(postprocessing stage)*
230
+
231
+ Applying photometric and geometric distortions prior to floating-point conversion ensures that operations such as
232
+ `Posterize` and `Solarize`, which are defined on integer pixel arithmetic, remain numerically well-founded, and that
233
+ fill values for geometric operations are expressed in the same integer domain as the source image.
234
+
235
+ ### 2. The RA Operation Space ($K = 14$)
236
+
237
+ All three algorithms draw from the **RA augmentation space**, a fixed pool of $K = 14$ operations. The pool is
238
+ partitioned into two subsets based on magnitude dependency.
239
+
240
+ #### Magnitude-Independent Operations (3 ops)
241
+
242
+ These operations ignore the sampled magnitude $m$ entirely.
243
+
244
+ | Operation | Description |
245
+ | :------------- | :---------------------------------------------------------------------------------------------------------- |
246
+ | `Identity` | Returns the image unmodified. |
247
+ | `AutoContrast` | Linearly scales the pixel intensity histogram so that the darkest pixel maps to 0 and the brightest to 255. |
248
+ | `Equalize` | Equalizes the image histogram per channel using a cumulative distribution function. |
249
+
250
+ #### Magnitude-Dependent Operations (11 ops)
251
+
252
+ These operations scale their physical intensity as a function of the sampled magnitude index $m$.
253
+
254
+ **Sign randomization.** For all geometric operations (`Rotate`, `ShearX`, `ShearY`, `TranslateX`, `TranslateY`) and all
255
+ color enhancement operations (`Brightness`, `Color`, `Contrast`, `Sharpness`), the direction of the applied
256
+ transformation is randomized bidirectionally. Given a raw physical magnitude $v$ computed from $m$, the applied value
257
+ is:
258
+
259
+ $$v' = v \cdot s, \quad s \sim \mathcal{U}\{-1, +1\}$$
260
+
261
+ This sign randomization is sampled independently per operation per sample, using a stateless seed derived from the
262
+ layer's random state.
263
+
264
+ **Geometric fill.** When pixels are shifted outside the image boundary by `Rotate`, `ShearX`, `ShearY`, `TranslateX`, or
265
+ `TranslateY`, the vacated regions are filled with a constant value (default: 128). Geometric operations use the
266
+ implementation's fixed nearest-neighbor interpolation for images.
267
+
268
+ For segmentation pipelines, these geometric operations reuse the same sampled parameters for the image and segmentation
269
+ map. The image uses bilinear interpolation, while the map uses nearest-neighbor interpolation and preserves its integer
270
+ dtype. Vacated map pixels use the configurable `mask_fill_value` (default `255`), which must be treated as an ignore
271
+ label by the training loss. Photometric operations continue to affect only the image.
272
+
273
+ **Solarize semantics.** `Solarize` inverts all pixel values that are greater than or equal to the computed threshold
274
+ $\tau$. Formally, for each pixel $p$:
275
+
276
+ $$p' = \begin{cases} 255 - p & \text{if } p \geq \tau \\ p & \text{otherwise} \end{cases}$$
277
+
278
+ where $\tau = 255 \cdot (1 - m / B)$. At $m = 0$, the threshold is 255 (no pixels inverted); at $m = B$, the threshold
279
+ is 0 (all pixels inverted).
280
+
281
+ ### 3. Magnitude Discretization and Physical Mappings
282
+
283
+ The magnitude scale is a **31-bin discrete framework** with bin indices $m \in \{0, 1, \ldots, 30\}$ and $B = 30$ (the
284
+ maximum bin index). This parameterization is the native scale of the `torchvision` (v0.13+) implementation of both
285
+ RandAugment and TrivialAugmentWide.
286
+
287
+ The table below specifies the physical mapping formula and the operation-specific bound for each of the two spaces. $W$
288
+ and $H$ denote the input image width and height at the moment the augmentation is applied.
289
+
290
+ | Operation | Sign Rand. | Physical Mapping | Standard Bound (RA / TA) | Wide Bound (TA-Wide) |
291
+ | :--------------- | :--------: | :-------------------------------------------------------------- | :-------------------------------- | :-------------------------------- |
292
+ | **Rotate** | Yes | $(m / B) \cdot \text{MaxDeg} \cdot s$ | 30.0° | 135.0° |
293
+ | **TranslateX** | Yes | $(m / B) \cdot \text{MaxPx}_X \cdot s$ | $(150 / 331) \times W$ | 32.0 px |
294
+ | **TranslateY** | Yes | $(m / B) \cdot \text{MaxPx}_Y \cdot s$ | $(150 / 331) \times H$ | 32.0 px |
295
+ | **ShearX** | Yes | $(m / B) \cdot \text{MaxShear} \cdot s$ | 0.3 | 0.99 |
296
+ | **ShearY** | Yes | $(m / B) \cdot \text{MaxShear} \cdot s$ | 0.3 | 0.99 |
297
+ | **Brightness** | Yes | $1.0 + (m / B) \cdot \text{MaxDelta} \cdot s$ | 0.9 | 0.99 |
298
+ | **Color** | Yes | $1.0 + (m / B) \cdot \text{MaxDelta} \cdot s$ | 0.9 | 0.99 |
299
+ | **Contrast** | Yes | $1.0 + (m / B) \cdot \text{MaxDelta} \cdot s$ | 0.9 | 0.99 |
300
+ | **Sharpness** | Yes | $1.0 + (m / B) \cdot \text{MaxDelta} \cdot s$ | 0.9 | 0.99 |
301
+ | **Posterize** | No | $8 - \mathrm{round}\!\left((m / B) \cdot \text{MaxBits}\right)$ | MaxBits = 4 (min 4 bits retained) | MaxBits = 6 (min 2 bits retained) |
302
+ | **Solarize** | No | $255.0 \cdot (1 - m / B)$ | threshold down to 0 | threshold down to 0 |
303
+ | **Identity** | — | — | — | — |
304
+ | **AutoContrast** | — | — | — | — |
305
+ | **Equalize** | — | — | — | — |
306
+
307
+ > **Note on TranslateX / TranslateY:** Translation is a deliberate exception to the "wider bounds" pattern. The TA-Wide
308
+ > space specifies a fixed ceiling of 32 px for both axes. For any image dimension exceeding approximately 71 px, the
309
+ > Standard RA space—whose ceiling scales proportionally with the image dimension—admits a **larger** maximum translation
310
+ > than the Wide space.
311
+
312
+ ### 4. Algorithm Specifications
313
+
314
+ #### 4.1 RandAugment (RA)
315
+
316
+ RandAugment (Cubuk et al., 2020) reduces the search space of AutoAugment from $\mathcal{O}(K^N)$ policies to two scalar
317
+ hyperparameters: the number of sequential operations $N$ and the global magnitude $M$.
318
+
319
+ **Procedure.** Given a training image $x$:
320
+
321
+ 1. Independently sample $N$ operation indices $k_1, \ldots, k_N$ uniformly at random **with replacement** from the pool
322
+ of $K$ operations.
323
+ 1. For each selected operation $T_{k_i}$, map the fixed global magnitude $M$ to a physical parameter via the
324
+ operation-specific formula in the table above, applying sign randomization where applicable.
325
+ 1. Apply the operations sequentially: $x \leftarrow T_{k_N}(\cdots T_{k_1}(x))$.
326
+
327
+ The magnitude $M$ is expressed on the **31-bin scale** ($M \in \{0, \ldots, 30\}$) used throughout `justdata`. An
328
+ optional magnitude perturbation $\sigma > 0$ samples the effective level per layer from $\mathcal{N}(M, \sigma^2)$,
329
+ clipped to $[0, B]$.
330
+
331
+ **API parameters** (`augment_strategy = "rand_augment"` or direct call to `rand_augment`):
332
+
333
+ | Parameter | Type | Default | Description |
334
+ | :------------------- | :------------------ | :------ | :---------------------------------------------------------------------------------------------------- |
335
+ | `num_layers` | `int` | 2 | Number of operations $N$ applied per image. |
336
+ | `magnitude` | `float` | 9.0 | Global magnitude $M$ on the 31-bin scale. |
337
+ | `magnitude_std` | `float` | 0.0 | Per-layer Gaussian magnitude noise $\sigma$. Set to 0.5 to replicate `timm` stochastic magnitude. |
338
+ | `prob_to_apply` | `float \| None` | `None` | If set, each layer is skipped with probability $1 - p$. |
339
+ | `rotate_max` | `float` | 30.0 | Maximum rotation angle in degrees. |
340
+ | `shear_max` | `float` | 0.3 | Maximum shear coefficient (Standard RA space). |
341
+ | `enhance_max` | `float` | 0.9 | Maximum delta for brightness, color, contrast, sharpness. |
342
+ | `posterize_max_bits` | `int` | 4 | Bits removed at maximum magnitude; min retained = $8 - \text{MaxBits}$. |
343
+ | `translate_const` | `float` | 100.0 | Absolute translate ceiling in pixels. For Standard RA, set to $(150/331) \times \text{image\_width}$. |
344
+ | `exclude_ops` | `list[str] \| None` | `None` | Operations to exclude from the sampling pool. |
345
+
346
+ **Published optimal hyperparameters and 31-bin scale conversion.** The original paper (Cubuk et al., 2020) reports
347
+ hyperparameters on an **11-level scale** ($M_{\text{paper}} \in \{0, \ldots, 10\}$). To replicate those results using
348
+ the 31-bin scale employed by `justdata`, apply the conversion $m = M_{\text{paper}} \times 3$.
349
+
350
+ | Dataset | Architecture | $N$ | $M_{\text{paper}}$ | $m$ (31-bin) |
351
+ | :---------- | :--------------------- | :-: | :----------------: | :----------: |
352
+ | CIFAR-10 | WideResNet-28-2 | 3 | 4 | 12 |
353
+ | CIFAR-10 | WideResNet-28-10 | 3 | 5 | 15 |
354
+ | CIFAR-10 | PyramidNet + ShakeDrop | 3 | 7 | 21 |
355
+ | CIFAR-10 | Shake-Shake | 3 | 9 | 27 |
356
+ | ImageNet-1K | ResNet-50 | 2 | 9 | 27 |
357
+ | ImageNet-1K | EfficientNet-B7 | 2 | — | 28† |
358
+
359
+ > †The EfficientNet-B7 value was reported on an extended scale beyond 10; cross-verify against the target codebase
360
+ > before use. The `torchvision` default of `magnitude=9` on the 31-bin scale corresponds to moderate augmentation and is
361
+ > **not** equivalent to the paper's $M_{\text{paper}} = 9$.
362
+
363
+ #### 4.2 TrivialAugment (TA)
364
+
365
+ TrivialAugment (Müller & Hutter, 2021) eliminates hyperparameter search entirely by selecting a single operation and
366
+ sampling its magnitude uniformly at random from the full discrete range on each forward pass.
367
+
368
+ **Procedure.** Given a training image $x$:
369
+
370
+ 1. Sample one operation index $k \sim \mathcal{U}\{1, \ldots, K\}$ uniformly from the 14-op RA pool.
371
+ 1. Sample a magnitude $m \sim \mathcal{U}\{0, 1, \ldots, 30\}$ uniformly from the full 31-bin range.
372
+ 1. Map $m$ to a physical parameter via the **Standard** bounds in the table above, applying sign randomization where
373
+ applicable.
374
+ 1. Apply the single operation: $x \leftarrow T_k(x)$.
375
+
376
+ The proportional translate ceiling is computed dynamically as $(150 / 331) \times W$ (image width), matching the
377
+ Standard RA space definition.
378
+
379
+ **API:** `augment_strategy = "trivial_augment"`. Accepts `translate_const` (float, optional; computed from image width
380
+ if not supplied) and `exclude_ops` (list of strings, optional).
381
+
382
+ #### 4.3 TrivialAugmentWide (TA-Wide)
383
+
384
+ TrivialAugmentWide (Müller & Hutter, 2021) is the native `torchvision` variant of TrivialAugment. It uses the same
385
+ zero-hyperparameter, single-operation protocol as baseline TA, but operates over the **Wide** magnitude bounds,
386
+ substantially expanding the geometric and photometric search range.
387
+
388
+ **Procedure.** Identical to TrivialAugment, with two differences:
389
+
390
+ 1. The **Wide** physical bounds from the table above are applied in place of the Standard bounds.
391
+ 1. The translate ceiling is a fixed **32 px** (not image-proportional).
392
+
393
+ Wide bounds summary:
394
+
395
+ | Transformation | Standard RA / TA | TA-Wide |
396
+ | :--------------------------------------------------------- | :---------------------------- | :-------- |
397
+ | Rotation range | ±30° | **±135°** |
398
+ | Shear range (X and Y) | ±0.3 | **±0.99** |
399
+ | Enhancement delta (Brightness, Color, Contrast, Sharpness) | ±0.9 | **±0.99** |
400
+ | Posterize (minimum bits retained) | 4 | **2** |
401
+ | Translation (fixed ceiling) | $(150/331) \times \text{dim}$ | **32 px** |
402
+
403
+ **API:** `augment_strategy = "trivial_augment_wide"`. Accepts `exclude_ops` (list of strings, optional). The wide bounds
404
+ are fixed by design and cannot be overridden via kwargs; to use custom bounds, call `rand_augment` directly with
405
+ `num_layers=1` and the desired parameters.
406
+
407
+ ### 5. Algorithm Comparison
408
+
409
+ | Property | RandAugment | TrivialAugment | TrivialAugmentWide |
410
+ | :--------------------------------- | :------------------------------------ | :--------------------------------------------- | :--------------------------------------------- |
411
+ | **Operations applied per image** | $N$ (tunable, with replacement) | 1 (fixed) | 1 (fixed) |
412
+ | **Magnitude $m$** | Fixed global $M$, constant across ops | Sampled: $m \sim \mathcal{U}\{0, \ldots, 30\}$ | Sampled: $m \sim \mathcal{U}\{0, \ldots, 30\}$ |
413
+ | **Hyperparameter search required** | Grid search over $(N, M)$ | None | None |
414
+ | **Transformation bounds** | Standard RA space | Standard RA space | Wide space |
415
+ | **Translate ceiling** | Configurable (default 100 px) | $(150/331) \times W$ (image-proportional) | 32 px (fixed) |
416
+ | **Reference implementation** | `torchvision` | `automl/trivialaugment` | `torchvision` |
417
+ | **`justdata` registry key** | `rand_augment` | `trivial_augment` | `trivial_augment_wide` |
418
+
419
+ ### 6. Non-RA Operations
420
+
421
+ `Invert`, `Cutout`, `SolarizeAdd`, and `Grayscale` are outside the fixed 14-op pool and cannot be selected through
422
+ RandAugment, TrivialAugment, or TrivialAugmentWide. The public `exclude_ops` parameter only removes operations from
423
+ the pool; listing these names has no effect. The `cutout_const` argument remains accepted for compatibility and
424
+ has no effect. Random erasing is available through the `random_erasing` late-augmentation stage.
425
+
426
+ ______________________________________________________________________
427
+
428
+ ## Supervised Learning — Validation Pipelines
429
+
430
+ Validation pipelines are strictly deterministic. The objective shifts from regularization to feature preservation and
431
+ scale alignment.
432
+
433
+ ### CIFAR-10 / CIFAR-100 Standard Validation
434
+
435
+ Because CIFAR images are inherently **32×32** and contain minimal background, spatial cropping destroys the primary
436
+ subject.
437
+
438
+ **Pipeline:** `ToImage()` -> `ToDtype(float32, scale=True)` -> `Normalize` (training-set statistics as above).
439
+
440
+ ### ImageNet-1K Standard Baseline (The 0.875 Rule)
441
+
442
+ For standard supervised models and baseline linear probing, the canonical **0.875** crop ratio discards peripheral
443
+ background.
444
+
445
+ **Pipeline:** `Resize(256, interpolation=Bicubic)` -> `CenterCrop(224)` -> `ToImage()` -> `ToDtype(float32, scale=True)`
446
+ -> `Normalize`.
447
+
448
+ ### ImageNet-1K Modern Recipes (FixRes Strategy)
449
+
450
+ Modern recipes correct train-test resolution discrepancies by manipulating the validation crop percentage (`crop_pct`).
451
+
452
+ - **A3 (Light) Validation:** Train at **160×160**, validate at **224×224**. Resize shorter edge to **≈236**, then
453
+ `CenterCrop(224)`.
454
+ - **A1 / A2 (Heavy/Moderate) Validation:** Default test at **224×224** (`crop_pct=1.0`, so `Resize(224)` ->
455
+ `CenterCrop(224)`). Accuracy improves further via FixRes evaluation at **288×288** (`Resize(288)` ->
456
+ `CenterCrop(288)`) as demonstrated in the RSB paper.
457
+
458
+ ______________________________________________________________________
459
+
460
+ ## The `timm` ImageNet Recipes (ResNet Strikes Back: A1/A2/A3)
461
+
462
+ The "ResNet Strikes Back" (RSB) recipes dynamically scale augmentation intensity and training schedules to match model
463
+ capacity.
464
+
465
+ > **Crucial context:** These recipes were designed specifically for **ResNet-family architectures**. ViTs typically use
466
+ > distinct recipes (e.g., DeiT, BEiT) with different Mixup $\alpha$, optimizers (AdamW), and loss functions. While the
467
+ > principle of scaling augmentation with model capacity generalizes, the specific hyperparameters below do not transfer
468
+ > directly to ViTs.
469
+
470
+ | Parameter | A1 (Heavy) | A2 (Moderate) | A3 (Light) |
471
+ | :---------------------- | :--------------------------------------------------- | :--------------------- | :-------------------------------------------- |
472
+ | **Target Architecture** | Large ResNets (e.g., ResNet-152/200) or high compute | ResNet-50 (standard) | ResNet-50 (fast) or smaller (e.g., ResNet-18) |
473
+ | **Training Resolution** | 224 | 224 | **160** (FixRes strategy) |
474
+ | **Test Resolution** | 224 (scales to 288 via FixRes) | 224 | **224** |
475
+ | **Epochs** | **600** | **300** | **100** |
476
+ | **Optimizer** | LAMB | LAMB | LAMB |
477
+ | **LR Schedule** | Cosine with warmup | Cosine with warmup | Cosine with warmup |
478
+ | **Loss Function** | **BCE** (per-class binary) | **BCE** | **CE** (standard) |
479
+ | **RandAugment** | $m \approx 7$, $n = 2$ | $m \approx 6$, $n = 2$ | $m \approx 6$, $n = 2$ |
480
+ | **Random Erasing** | `p=0.35` | `p=0.25` | **Disabled** (`p=0.0`) |
481
+ | **Repeated Aug (RA)** | Enabled (3×) | Enabled (3×) | **Disabled** |
482
+ | **Mixup** $\alpha$ | 0.2 | 0.2 | 0.1 |
483
+ | **CutMix** $\alpha$ | 1.0 | 1.0 | 1.0 |
484
+ | **Stochastic Depth** | Capacity-dependent (e.g., 0.05+) | 0.0 | 0.0 |
485
+ | **EMA** | Yes | Yes | No (or lighter) |
486
+ | **Weight Decay** | 0.02 | 0.02 | 0.02 |
487
+
488
+ *Note: RandAugment parameter $n$ defaults to 2 per the original specification, though exact magnitude strings fluctuate
489
+ across `timm` versions.*
490
+
491
+ ______________________________________________________________________
492
+
493
+ ## Self-Supervised Learning Pipeline (DINOv2)
494
+
495
+ DINOv2 employs a Teacher-Student knowledge distillation framework operating on multi-crop asymmetry to force the
496
+ learning of semantic invariance over low-level frequency matching.
497
+
498
+ ### Multi-Crop Geometric Strategy
499
+
500
+ - **Global Crops (Context):** 2 crops at **224×224**. Scale: **(0.32, 1.0)**. Passed to both Teacher and Student.
501
+ - **Local Crops (Detail):** 8 crops at **96×96** (default). *Use **98×98** ($14 \times 7$) to avoid positional embedding
502
+ interpolation when using ViT-14 backbones.* Scale: **(0.05, 0.32)**. Passed to Student only.
503
+
504
+ ### Asymmetric Pipeline Implementation
505
+
506
+ The per-crop asymmetry is structurally enforced by three distinct `Compose` pipelines rather than conditional branching
507
+ within a single block. Each source image passes through all three pipelines to produce the full 10-crop suite.
508
+
509
+ - **`global_transform_1`**: Global Crop 1. Enforces strict blurring (`p=1.0`), disables solarization (`p=0.0`).
510
+ - **`global_transform_2`**: Global Crop 2. Minimizes blurring (`p=0.1`), enables solarization (`p=0.2`).
511
+ - **`local_transform`**: The 8 Local Crops. Moderate blurring (`p=0.5`), disables solarization (`p=0.0`).
512
+
513
+ ### Execution Order and Domain Separation (Per Crop)
514
+
515
+ | Step | Operation | Parameters / Per-Crop Asymmetry | Domain |
516
+ | :--- | :--------------------- | :--------------------------------------------------------------------------------------------------------------- | :----------------- |
517
+ | 1 | `RandomResizedCrop` | Aspect ratio **(0.75, 1.33)**, Bicubic interpolation. | Image |
518
+ | 2 | `RandomHorizontalFlip` | `p=0.5` (all crops) | Image |
519
+ | 3 | `ColorJitter` | `p=0.8` (all crops). `b=0.4, c=0.4, s=0.2, h=0.1` | Image |
520
+ | 4 | `RandomGrayscale` | `p=0.2` (all crops) | Image |
521
+ | 5 | `GaussianBlur` | $\sigma \sim \mathrm{Uniform}(0.1, 2.0)$, dynamic kernel. Global 1: `p=1.0` · Global 2: `p=0.1` · Local: `p=0.5` | Image |
522
+ | 6 | `Solarization` | Invert pixels $> 128$. Global 1: `p=0.0` · Global 2: `p=0.2` · Local: `p=0.0` | Image |
523
+ | 7 | Convert & Scale | `ToImage()` -> `ToDtype(float32, scale=True)` | Image -> Tensor |
524
+ | 8 | `Normalize` | ImageNet `mean` and `std`. | Tensor (zero-mean) |
525
+
526
+ ### SSL Downstream Evaluation
527
+
528
+ **Image-Level Classification (Linear Probing / $k$-NN):** Standard supervised inference transforms:
529
+ `Resize(256, Bicubic)` -> `CenterCrop(224)` -> `ToImage()` -> `ToDtype(float32)` -> `Normalize`. Features are extracted
530
+ from the `[CLS]` token or a concatenation of `[CLS]` and average-pooled patch tokens.
531
+
532
+ **Dense Tasks (Segmentation / Depth Validation — Patch Alignment):** To avoid dropping boundary pixels or forcing
533
+ complex interpolation during dense evaluation, images are resized to the target scale and padded (reflection or zero) on
534
+ the bottom and right edges such that both height and width are exact multiples of the ViT patch size (e.g., 14). This is
535
+ implemented in `justdata.vision.transforms.pad_to_patch_multiple`.
536
+
537
+ ______________________________________________________________________
538
+
539
+ ## Registry System
540
+
541
+ All extensible components in `justdata` use a decorator-based registry pattern with thread-safe lookups.
542
+
543
+ | Registry | Decorator | Lookup |
544
+ | :----------------- | :------------------------------------------------ | :------------------------------------------------------------- |
545
+ | Crop strategies | `@register_crop_strategy(name)` | `justdata.vision.augmentations.get_crop_strategy(name)` |
546
+ | Augment strategies | `@register_augment_strategy(name)` | `justdata.vision.augmentations.get_augment_strategy(name)` |
547
+ | Corruptions | `@register_corruption(name, descriptor=...)` | `justdata.vision.corruptions.apply_corruption(...)` |
548
+ | Dataset adapters | `@register_adapter(dataset_name)` | `justdata.core.get_adapter(dataset_name)` |
549
+ | Source loaders | `@register_source_loader(prefix)` | `justdata.core.get_source_loader(dataset_name)` |
550
+ | Pipelines | `@register_pipeline("modality/task")` | `justdata.core.get_pipeline(...)` |
551
+ | Dataset metadata | `register_dataset(name, task_type, modality=...)` | `justdata.core.get_dataset_info(name)` |
552
+ | Audio frontends | `@register_audio_frontend(name)` | `justdata.acoustic.get_audio_frontend(name)` |
553
+ | Audio components | `@register_audio_*` decorators | `justdata.acoustic.get_audio_*`, `list_audio_*`, `has_audio_*` |
554
+
555
+ `get_pipeline` is the high-level resolver: it infers the task type from the dataset name, merges preset defaults with
556
+ user-supplied kwargs (via smart merge; see below), and invokes the appropriate pipeline factory.
557
+
558
+ **Built-in crop strategies:** `random_resized`, `random_resized_hvflip`, `random_pad`, `random_hflip`,
559
+ `resize_random_hflip`, `random_rot90_hflip`.
560
+
561
+ **Built-in augment strategies:** `rand_augment`, `trivial_augment`, `trivial_augment_wide`, `color_jitter`, `none`.
562
+
563
+ Crop-specific parameters are passed through `aug_kwargs["crop_kwargs"]`. `size`, `seed`, `interpolation`, `padding`, and
564
+ `pad_mode` remain controlled by the existing top-level augmentation fields and are rejected inside `crop_kwargs`,
565
+ avoiding ambiguous precedence. For example, the FMoW M1 crop is fully declarative:
566
+
567
+ ```python
568
+ pipeline = get_pipeline(
569
+ dataset="wilds:fmow",
570
+ aug_kwargs={
571
+ "enable": True,
572
+ "image_size": 224,
573
+ "crop_type": "random_resized_hvflip",
574
+ "interpolation": "bicubic",
575
+ "crop_kwargs": {
576
+ "scale": (0.85, 1.0),
577
+ "ratio": (0.90, 1.10),
578
+ "horizontal_flip_probability": 0.5,
579
+ "vertical_flip_probability": 0.5,
580
+ },
581
+ },
582
+ )
583
+ ```
584
+
585
+ The acoustic package registers audio decoders, resamplers, channel strategies, segment strategies, frontends,
586
+ augmentations, normalizations, eval views, postprocessors, and corruptions. Use `list_audio_*` helpers to inspect
587
+ registered acoustic components.
588
+
589
+ ______________________________________________________________________
590
+
591
+ ## Presets and Smart Merging
592
+
593
+ `justdata.vision.presets` stores dataset-specific default kwargs for all four vision pipeline stages. The vision
594
+ `_default` preset (ImageNet statistics, 224px, RandAugment) serves as the fallback for vision only.
595
+
596
+ **Available presets:**
597
+
598
+ | Preset | Description |
599
+ | :---------------- | :-------------------------------------------------------------- |
600
+ | `_default` | ImageNet-1K statistics, 224px, RandAugment, modern branch |
601
+ | `cifar` | 32px, TrivialAugmentWide, CIFAR-10 normalization, no resizing |
602
+ | `cifar100` | 32px, TrivialAugmentWide, CIFAR-100 normalization |
603
+ | `imagenet_resnet` | ImageNet statistics, legacy branch with ColorJitter |
604
+ | `imagenet_a1` | RSB A1: heavy augmentation, BCE loss, 600 epochs |
605
+ | `imagenet_a2` | RSB A2: moderate augmentation, BCE loss, 300 epochs |
606
+ | `imagenet_a3` | RSB A3: light augmentation, CE loss, 160px training |
607
+ | `dinov2` | Asymmetric multi-crop SSL pipeline |
608
+ | `wilds:*` | WILDS benchmark defaults; matching `_strong` presets are opt-in |
609
+
610
+ `merge_with_presets(dataset, user_kwargs)` implements a **smart merge**: user-supplied kwargs that are identical to the
611
+ `_default` preset values are treated as "not explicitly overridden," allowing dataset-specific preset values to take
612
+ precedence. Only kwargs that genuinely differ from the defaults are considered intentional user overrides.
613
+
614
+ Resolved presets are serializable and hashable across modalities. Use `get_resolved_preset(name)` from
615
+ `justdata.vision.presets`, `justdata.acoustic.presets`, or `justdata.core.presets` to obtain an object with `.to_json()`
616
+ and `.hash()`. Hashes use canonical JSON with sorted keys and a 16-character SHA-256 prefix.
617
+
618
+ Acoustic presets are typed with `AudioPreset` and nested frozen config dataclasses for preprocessing, segmentation,
619
+ frontends, labels, normalization, train augment settings, eval views, layout, and metadata policy. The `justdata.audio`
620
+ namespace is a compatibility alias for `justdata.acoustic`.
621
+
622
+ See [docs/presets.md](docs/presets.md) for acoustic preset contracts, including EfficientAT/DyMN, PaSST, and CED.
623
+
624
+ ### Automatic preset resolution
625
+
626
+ When a vision dataset has a registered preset (e.g., `cifar10` -> `cifar`, `cifar100` -> `cifar100`), `get_pipeline`
627
+ automatically applies it. Vision datasets without a dedicated preset fall back to the vision `_default`.
628
+
629
+ ```python
630
+ import justdata.vision
631
+ from justdata.core.registry import get_pipeline
632
+
633
+ # cifar10 automatically gets the 'cifar' preset (32px, TrivialAugmentWide, CIFAR-10 stats)
634
+ pipeline = get_pipeline(dataset="cifar10")
635
+ ```
636
+
637
+ ### Applying a named preset to any dataset
638
+
639
+ The `dataset` argument in `get_pipeline` drives preset lookup, not just task inference. To apply a specific named preset
640
+ to a dataset that does not have its own preset (e.g., using `imagenet_a3` for `imagenette`), pass it as `preset`:
641
+
642
+ ```python
643
+ import justdata.vision
644
+ from justdata.core.loader import load_ds
645
+ from justdata.core.registry import get_pipeline
646
+
647
+ # Resolve the A3 (RSB light) pipeline for imagenette
648
+ pipeline = get_pipeline(
649
+ dataset="imagenette",
650
+ preset="imagenet_a3", # drives preset lookup: 160px train, 224px val, RandAugment m=6
651
+ )
652
+
653
+ train_ds, N = load_ds(
654
+ dataset_names_arg=["imagenette"], # actual dataset to load
655
+ splits_arg={"imagenette": ["train"]},
656
+ dataset_type="train",
657
+ batch_size=128,
658
+ seed=42,
659
+ pipeline=pipeline,
660
+ num_classes=10,
661
+ cache_dataset=False,
662
+ )
663
+ ```
664
+
665
+ The validation pipeline uses the same preset name; the A3 preset's FixRes strategy (`train_image_size=160`,
666
+ `val_resize_size=236`) is applied automatically:
667
+
668
+ ```python
669
+ # The same pipeline can be used for validation; `load_ds` automatically sets `is_training=False` based on `dataset_type`
670
+ # and applies the deterministic center-crop resize (FixRes 236 → CenterCrop 224)
671
+ val_ds, N = load_ds(
672
+ dataset_names_arg=["imagenette"],
673
+ splits_arg={"imagenette": ["validation"]},
674
+ dataset_type="validation",
675
+ batch_size=256,
676
+ seed=0,
677
+ pipeline=pipeline,
678
+ num_classes=10,
679
+ cache_dataset=False,
680
+ )
681
+ ```
682
+
683
+ ______________________________________________________________________
684
+
685
+ ## Acoustic Pipelines
686
+
687
+ Import `justdata.acoustic` before resolving built-in acoustic datasets or pipelines. Acoustic samples use the canonical
688
+ keys `waveform`, `sample_rate`, optional `label`, `features`, `duration`, and `metadata`.
689
+
690
+ ```python
691
+ import justdata.acoustic
692
+ from justdata.core.loader import load_ds
693
+ from justdata.core.registry import get_pipeline
694
+
695
+ pipeline = get_pipeline(
696
+ dataset="dcase2025_task1",
697
+ preset="dcase2025_task1_efficientat_32k_1s",
698
+ )
699
+
700
+ ds, n = load_ds(
701
+ dataset_names_arg=["dcase2025:task1"],
702
+ splits_arg={"dcase2025:task1": ["dev_train_25"]},
703
+ dataset_type="train",
704
+ batch_size=64,
705
+ seed=0,
706
+ pipeline=pipeline,
707
+ num_classes=10,
708
+ cache_dataset=False,
709
+ data_dir="/path/to/dcase",
710
+ metadata_mode="numeric_only",
711
+ as_numpy=True,
712
+ )
713
+ ```
714
+
715
+ Modality documentation:
716
+
717
+ - [docs/vision.md](docs/vision.md): vision schema, four stages, preset contracts, metadata modes, Mini-C, and parity
718
+ matrix.
719
+ - [docs/acoustic.md](docs/acoustic.md): canonical schema, four stages, metadata modes, golden tests, corruption
720
+ benchmark, and parity matrix.
721
+ - [docs/dcase2025.md](docs/dcase2025.md): DCASE Task 1 source/target helpers and split safety.
722
+ - [docs/presets.md](docs/presets.md): vision and acoustic preset selection and hashable contracts.
723
+ - [docs/golden_tests.md](docs/golden_tests.md): optional golden compatibility test workflow.
724
+
725
+ Examples are split by modality under `examples/vision/` and `examples/acoustic/`. Each directory includes loading,
726
+ Hugging Face source, statistics, and corruption benchmark examples.
727
+
728
+ ______________________________________________________________________
729
+
730
+ ## Dataset Adapters
731
+
732
+ Core adapters normalize raw records into the modality-specific schema expected by a selected pipeline. `justdata.core`
733
+ itself is schema-neutral, and the identity adapter is applied when no dataset-specific adapter is registered.
734
+
735
+ ### Vision adapter
736
+
737
+ Vision pipelines expect `image`, optional `label`, and task-specific fields such as `mask`.
738
+
739
+ ```python
740
+ from justdata.core.adapters import register_adapter
741
+
742
+ @register_adapter("my_dataset")
743
+ def my_adapter(sample):
744
+ return {"image": sample["img"], "label": sample["class_id"]}
745
+ ```
746
+
747
+ ### Acoustic adapter
748
+
749
+ Acoustic pipelines expect `waveform`, `sample_rate`, and an optional `label`.
750
+
751
+ ```python
752
+ from justdata.core.adapters import register_adapter
753
+
754
+ @register_adapter("my_audio_dataset")
755
+ def my_audio_adapter(sample):
756
+ result = {
757
+ "waveform": sample["audio"],
758
+ "sample_rate": sample["sampling_rate"],
759
+ }
760
+ if "target" in sample:
761
+ result["label"] = sample["target"]
762
+ return result
763
+ ```
764
+
765
+ ______________________________________________________________________
766
+
767
+ ## Mini-C Corruption Benchmark
768
+
769
+ `create_minic_datasets` constructs finalized corruption evaluation datasets by forking from a preprocessed RGB dataset.
770
+ Corruption runs after decoding and rank/channel normalization, but before resize, float conversion, normalization,
771
+ batching, and padding. Pass `cache_dataset=True` with an explicit disk path when avoiding source re-reads across
772
+ corruptions is worth the storage cost; otherwise the base remains streaming.
773
+
774
+ The original Mini-C family names remain pinned to their `1.0.0` behavior:
775
+
776
+ | Name | Version 1 implementation |
777
+ | :-------- | :-------------------------------------------------------------------- |
778
+ | `blur` | Defocus blur with a disk kernel and alias Gaussian filter |
779
+ | `noise` | Additive Gaussian noise using the legacy absolute standard deviations |
780
+ | `digital` | Nearest-neighbor pixelation |
781
+ | `weather` | Synthetic snow |
782
+
783
+ Five exact-name TensorFlow-native operators are also available at version `1.0.0`: `gaussian_blur`, `gaussian_noise`,
784
+ `jpeg_compression`, `contrast_reduction`, and `brightness_reduction`. Their immutable descriptors contain the severity
785
+ table, domains, dtype/shape contract, seed policy, clipping and rounding policy, backend identity, and codec/filter
786
+ settings. Use `get_corruption_descriptor(name, version)` or `list_corruption_descriptors()` to serialize and fingerprint
787
+ these semantics.
788
+
789
+ For a caller-owned scientific seed, use exact version dispatch directly:
790
+
791
+ ```python
792
+ import tensorflow as tf
793
+
794
+ from justdata.vision.corruptions import (
795
+ apply_corruption,
796
+ get_corruption_descriptor,
797
+ )
798
+
799
+ descriptor = get_corruption_descriptor("gaussian_noise", "1.0.0")
800
+ corrupted = apply_corruption(
801
+ decoded_rgb_uint8,
802
+ name=descriptor.name,
803
+ version=descriptor.version,
804
+ severity=3,
805
+ seed=tf.constant([123, 456], dtype=tf.int32),
806
+ )
807
+ ```
808
+
809
+ The complete seed is supplied by the caller; no global RNG is read. `gaussian_noise@1.0.0` uses TensorFlow Philox. The
810
+ JPEG descriptor fixes encode and decode options and is repeatable for a fixed TensorFlow/codec build, but does not claim
811
+ byte identity across unrelated TensorFlow or codec versions.
812
+
813
+ ```python
814
+ import justdata.vision
815
+ from justdata.core.registry import get_pipeline
816
+ from justdata.vision.minic import create_minic_datasets
817
+
818
+ pipeline = get_pipeline(dataset="imagenet")
819
+
820
+ datasets, n = create_minic_datasets(
821
+ corruption_types=["gaussian_noise", "jpeg_compression", "blur"],
822
+ severity=3,
823
+ dataset_names_arg=["imagenet2012"],
824
+ splits_arg={"imagenet2012": ["validation"]},
825
+ dataset_type="validation",
826
+ batch_size=256,
827
+ seed=0,
828
+ pipeline=pipeline,
829
+ num_classes=1000,
830
+ )
831
+ ```
832
+
833
+ With `metadata_mode="full"`, finalized samples include `corruption`, `corruption_version`, `corruption_identity`,
834
+ `corruption_identity_hash`, `severity`, and `corruption_domain`. `numeric_only` retains the numeric identity hash and
835
+ severity; `none` removes metadata according to the shared core contract. The dataset helper preserves legacy
836
+ enumeration-position seed salting. Consumers with their own sample-level PRNG lineage should call `apply_corruption`
837
+ directly.
838
+
839
+ ______________________________________________________________________
840
+
841
+ ## Audio Corruption Benchmark
842
+
843
+ `create_audio_corruption_datasets` mirrors Mini-C for acoustic evaluation. It applies deterministic severity 1-5
844
+ corruptions in the waveform or spectrogram domain, attaches corruption metadata, runs the normal postprocessing stage,
845
+ and preserves `padding_mask`.
846
+
847
+ ```python
848
+ import justdata.acoustic
849
+ from justdata.acoustic.corruptions.datasets import create_audio_corruption_datasets
850
+ from justdata.core.registry import get_pipeline
851
+
852
+ pipeline = get_pipeline(
853
+ dataset="dcase2025_task1",
854
+ preset="dcase2025_task1_efficientat_32k_1s",
855
+ )
856
+
857
+ datasets, n = create_audio_corruption_datasets(
858
+ corruption_types=["additive_white_noise", "clipping"],
859
+ severity=3,
860
+ base_dataset="dcase2025:task1",
861
+ preset="dcase2025_task1_efficientat_32k_1s",
862
+ split="dev_test",
863
+ pipeline=pipeline,
864
+ batch_size=64,
865
+ seed=0,
866
+ num_classes=10,
867
+ metadata_mode="numeric_only",
868
+ )
869
+ ```
870
+
871
+ ______________________________________________________________________
872
+
873
+ ## Usage
874
+
875
+ ### Basic Classification Pipeline
876
+
877
+ ```python
878
+ import justdata.vision
879
+ from justdata.core.loader import load_ds
880
+ from justdata.core.registry import get_pipeline
881
+
882
+ pipeline = get_pipeline(dataset="cifar10")
883
+
884
+ train_ds, N = load_ds(
885
+ dataset_names_arg=["cifar10"],
886
+ splits_arg={"cifar10": ["train"]},
887
+ dataset_type="train",
888
+ batch_size=128,
889
+ seed=42,
890
+ pipeline=pipeline,
891
+ num_classes=10,
892
+ # CIFAR-10 is small enough for an intentional memory cache.
893
+ cache_dataset=True,
894
+ )
895
+ ```
896
+
897
+ ### Reusable, Explicitly Seeded Epochs
898
+
899
+ Use `return_raw_ds=True` to prepare the source, pipeline, preprocessing, cache,
900
+ and filters once, then materialize the complete remaining training pipeline for
901
+ each epoch:
902
+
903
+ ```python
904
+ prepared_train, tools = load_ds(
905
+ dataset_names_arg=["cifar10"],
906
+ splits_arg={"cifar10": ["train"]},
907
+ dataset_type="train",
908
+ batch_size=128,
909
+ seed=0,
910
+ pipeline=pipeline,
911
+ num_classes=10,
912
+ cache_dataset=False,
913
+ deterministic=True,
914
+ return_raw_ds=True,
915
+ )
916
+
917
+ for epoch in range(num_epochs):
918
+ train_iterator, n_batches = tools["finalize_epoch"](
919
+ prepared_train,
920
+ seed=derive_epoch_seed(epoch),
921
+ as_numpy=True,
922
+ )
923
+ train_one_epoch(train_iterator)
924
+ ```
925
+
926
+ `finalize_epoch` applies standard augmentation, shuffle, postprocessing,
927
+ batching, late augmentation, padding, and prefetching. The epoch seed is split
928
+ into standard- and late-augmentation seeds, with source and batch indices folded
929
+ in. Shuffle uses the epoch seed with reshuffling disabled on the materialized
930
+ dataset. With `deterministic=True`, repeating a seed therefore reproduces the
931
+ epoch independently of previous iterator creation or consumption, including
932
+ when the returned TensorFlow dataset is iterated more than once.
933
+
934
+ For an augmentation callback that depends only on its input sample and supplied
935
+ seed, pass `augment_is_stateless=True` to `finalize_epoch` to run standard
936
+ augmentation concurrently using `map_parallel_calls` (or `AUTOTUNE`). With
937
+ `deterministic=True`, sample order and indexed RNG seeds remain unchanged:
938
+
939
+ ```python
940
+ train_iterator, n_batches = tools["finalize_epoch"](
941
+ prepared_train,
942
+ seed=derive_epoch_seed(epoch),
943
+ augment_is_stateless=True,
944
+ as_numpy=True,
945
+ )
946
+ ```
947
+
948
+ This flag is the caller's assertion that the augmentation callback uses no
949
+ stateful RNG, mutable state, or side effects. It defaults to `False`, preserving
950
+ serial standard augmentation for deterministic epochs. It does not change the
951
+ one-shot `load_ds` or `finalize_fn` seed scheduling.
952
+
953
+ With `cache_dataset=False`, source samples, preprocessing, and filters still run
954
+ on every iteration; only loader and graph preparation are reused. A fresh NumPy
955
+ iterator is created by each `finalize_epoch(..., as_numpy=True)` call.
956
+
957
+ `finalize_epoch` rejects `cache_model_inputs=True` when training or evaluation
958
+ augmentation is enabled because that downstream cache intentionally freezes the
959
+ first sampled augmented views. Existing one-shot `load_ds` and `finalize_fn`
960
+ behavior is unchanged.
961
+
962
+ ### Loading a Hugging Face Dataset
963
+
964
+ ```python
965
+ train_ds, n_batches = load_ds(
966
+ dataset_names_arg=["hf:cifar10"],
967
+ splits_arg={"hf:cifar10": ["train"]},
968
+ cache_dataset=False,
969
+ ...
970
+ )
971
+ ```
972
+
973
+ `load_ds` returns the dataset and its batch cardinality. The cardinality is a Python integer when TensorFlow can
974
+ determine it and `None` for unknown or infinite pipelines.
975
+
976
+ For remote/downloaded sources, `data_dir` is a cache root. justdata namespaces source-owned caches under it: `tfds/`,
977
+ `hf/vision/`, `hf/acoustic/`, `wilds/`, and `zenodo/`. If omitted, the root is `~/.cache/justdata`.
978
+
979
+ Loader caches are separate from source-owned caches. `cache_dataset/cache_path` caches decoded, preprocessed samples
980
+ before augmentation. Loader caching is off by default, so datasets remain streaming when `cache_dataset` is omitted. Set
981
+ `cache_dataset=True` with an empty `cache_path` to opt into memory caching, or provide a nonempty path to cache on the
982
+ filesystem. Large datasets should use an explicit disk path or remain uncached. `cache_model_inputs` and
983
+ `model_input_cache_path` cache resized, normalized model inputs before batching. Use different paths for the two cache
984
+ stages. This default changes performance, not output values.
985
+
986
+ ### Loading a WILDS Dataset
987
+
988
+ WILDS image classification datasets use the `wilds:` source prefix. Source options such as FMoW temporal split schemes
989
+ live in the dataset string; when using a `splits_arg` dictionary, reuse that exact string as the key. Downloads are
990
+ disabled by default (`download=false`). To download through WILDS under `data_dir/wilds`, add `download=true` to the
991
+ dataset string. Use `&` between query options, not a second `?`. The automatic presets are benchmark-faithful:
992
+ Camelyon17 96 px, FMoW 224 px, iWildCam 448 px, and RxRx1 256 px with per-image channel standardization. Use
993
+ `preset="wilds:fmow_strong"` or another `_strong` name to opt into stronger training augmentation.
994
+
995
+ ```python
996
+ local_ssd = "/local_ssd/justdata"
997
+ wilds_ds = "wilds:fmow?split_scheme=time_after_2016&download=true"
998
+ pipeline = get_pipeline(dataset="wilds:fmow")
999
+
1000
+ train_ds, N = load_ds(
1001
+ dataset_names_arg=[wilds_ds],
1002
+ splits_arg={wilds_ds: ["train"]},
1003
+ dataset_type="train",
1004
+ batch_size=32,
1005
+ seed=42,
1006
+ pipeline=pipeline,
1007
+ num_classes=62,
1008
+ data_dir=f"{local_ssd}/sources",
1009
+ cache_dataset=True,
1010
+ cache_path=f"{local_ssd}/decoded/fmow-train",
1011
+ cache_model_inputs=True,
1012
+ model_input_cache_path=f"{local_ssd}/model-inputs/fmow-train-224",
1013
+ allow_train_model_input_cache=True,
1014
+ metadata_mode="numeric_only",
1015
+ )
1016
+ ```
1017
+
1018
+ FMoW source inventories can opt into authoritative sequence identity and
1019
+ acquisition time without changing the default WILDS signature:
1020
+
1021
+ ```python
1022
+ from justdata.core import fetch_ds
1023
+
1024
+ fmow = (
1025
+ "wilds:fmow?split_scheme=official&version=1.1&download=false"
1026
+ "&source_metadata=location_id,timestamp"
1027
+ )
1028
+ inventory = fetch_ds([fmow], {fmow: ["train", "id_val", "id_test", "val"]})
1029
+
1030
+ for sample in inventory.as_numpy_iterator():
1031
+ source = sample["metadata"]["wilds_source"]
1032
+ location_id = source["location_id"] # UTF-8 bytes
1033
+ timestamp = source["timestamp"] # UTF-8 bytes
1034
+ ```
1035
+
1036
+ The option accepts only `location_id` and `timestamp`. JustData maps every
1037
+ emitted `wilds_index` through WILDS' authoritative `full_idxs` mapping:
1038
+ `location_id` is the exact original FMoW sequence-directory basename, and
1039
+ `timestamp` preserves the source timezone-aware ISO-8601 text. Invalid fields,
1040
+ target-equivalent fields, missing source columns, or unreliable mappings fail
1041
+ closed. The `wilds_source` mapping is absent without the opt-in; it is retained
1042
+ by `metadata_mode="full"` and removed by `numeric_only`.
1043
+
1044
+ The base `wilds:fmow` preset has no stochastic per-sample training augmentation, so train model-input caching is safe
1045
+ when explicitly opted in. Do not use train model-input caching with `wilds:fmow_strong` unless freezing the first pass
1046
+ of stochastic augmentation is intentional.
1047
+
1048
+ ### Applying a Named Preset
1049
+
1050
+ To use a specific preset for any dataset, pass the preset name as `preset`:
1051
+
1052
+ ```python
1053
+ # Load imagenette with the RSB A3 (light) recipe: 160px training, RandAugment m=6, Mixup α=0.1
1054
+ pipeline = get_pipeline(
1055
+ dataset="imagenette",
1056
+ preset="imagenet_a3", # apply the A3 preset to the imagenette task
1057
+ )
1058
+
1059
+ train_ds, N = load_ds(
1060
+ dataset_names_arg=["imagenette"],
1061
+ splits_arg={"imagenette": ["train"]},
1062
+ dataset_type="train",
1063
+ batch_size=128,
1064
+ seed=42,
1065
+ pipeline=pipeline,
1066
+ num_classes=10,
1067
+ cache_dataset=False,
1068
+ )
1069
+ ```
1070
+
1071
+ ### Overriding Preset Parameters
1072
+
1073
+ ```python
1074
+ pipeline = get_pipeline(
1075
+ dataset="imagenet",
1076
+ aug_kwargs={"augment_type": "trivial_augment"}, # overrides preset default
1077
+ )
1078
+ ```
1079
+
1080
+ ### DINOv2 SSL Pipeline
1081
+
1082
+ ```python
1083
+ pipeline = get_pipeline(
1084
+ preset="dinov2",
1085
+ pipeline_name="vision/classification",
1086
+ )
1087
+ ```
1088
+
1089
+ ______________________________________________________________________
1090
+
1091
+ ## Development
1092
+
1093
+ This project uses [devenv](https://devenv.sh/) (Nix-based) with `uv` for Python dependency management.
1094
+
1095
+ ```bash
1096
+ devenv shell # enter the development environment
1097
+ direnv allow # approve automatic devenv activation once
1098
+ uv sync # install/update dependencies
1099
+ uv run pytest # run all tests
1100
+ uv run ruff check . # run lint checks
1101
+ uv run ruff format --check . # check formatting
1102
+ uv run pytest tests/path/to/test_file.py::test_name # run a single test
1103
+ ```
1104
+
1105
+ The project targets Python 3.12 (see `.python-version`). `LD_LIBRARY_PATH` is configured by devenv for native libraries.
1106
+
1107
+ See [Performance checks](benchmarks/README.md) for reproducible CPU benchmarks and the performance audit results.
1108
+
1109
+ GitLab runs `sh tests/doctor/test_lint.sh` in a pinned Debian-based uv image. This installs only the `lint` dependency
1110
+ group and provides the standard Linux dynamic loader required by Ruff's PyPI executable, which the Nix image lacks.
1111
+
1112
+ ### Releases
1113
+
1114
+ GitLab builds a wheel and source distribution after lint, the default test suite,
1115
+ and all Python 3.11–3.13 package-support jobs pass. Build artifacts are retained
1116
+ for one week. Tag pipelines publish those artifacts to
1117
+ [PyPI](https://pypi.org/project/justdata/) after the existing manual `golden` job
1118
+ also passes; start that job in GitLab to complete a release.
1119
+
1120
+ Before tagging, update `pyproject.toml`, `src/justdata/__init__.py`, and
1121
+ `CHANGELOG.md`, then run `uv lock`. Push a tag matching the package version, with
1122
+ an optional `v` prefix (for example, `v1.1.0` or `1.1.0`). Publishing rejects tags
1123
+ that disagree with either version declaration. Branch pipelines build artifacts
1124
+ without publishing.
1125
+
1126
+ Configure a [PyPI GitLab trusted publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/)
1127
+ for the `justdata` project with namespace `rhizome-labs/public`, project
1128
+ `justdata`, pipeline path `.gitlab-ci.yml`, and environment `release`. The
1129
+ `publish` job requests a GitLab ID token with audience `pypi` and requires trusted
1130
+ publishing; no stored PyPI API token is needed.