justdata 1.0.0__py3-none-any.whl
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.
- justdata/__init__.py +3 -0
- justdata/acoustic/__init__.py +381 -0
- justdata/acoustic/adapters.py +329 -0
- justdata/acoustic/augment/__init__.py +119 -0
- justdata/acoustic/augment/batch.py +813 -0
- justdata/acoustic/augment/configs.py +204 -0
- justdata/acoustic/augment/patchout.py +331 -0
- justdata/acoustic/augment/spectrogram.py +806 -0
- justdata/acoustic/augment/waveform.py +879 -0
- justdata/acoustic/batching.py +27 -0
- justdata/acoustic/channel.py +53 -0
- justdata/acoustic/compat/__init__.py +95 -0
- justdata/acoustic/compat/ast.py +626 -0
- justdata/acoustic/compat/ced.py +152 -0
- justdata/acoustic/compat/efficientat.py +243 -0
- justdata/acoustic/compat/panns.py +115 -0
- justdata/acoustic/compat/passt.py +191 -0
- justdata/acoustic/configs.py +519 -0
- justdata/acoustic/corruptions/__init__.py +33 -0
- justdata/acoustic/corruptions/codec.py +92 -0
- justdata/acoustic/corruptions/datasets.py +155 -0
- justdata/acoustic/corruptions/device.py +39 -0
- justdata/acoustic/corruptions/dynamics.py +55 -0
- justdata/acoustic/corruptions/filters.py +105 -0
- justdata/acoustic/corruptions/noise.py +173 -0
- justdata/acoustic/corruptions/registry.py +230 -0
- justdata/acoustic/corruptions/reverb.py +49 -0
- justdata/acoustic/corruptions/timefreq.py +127 -0
- justdata/acoustic/datasets.py +52 -0
- justdata/acoustic/dcase2025.py +814 -0
- justdata/acoustic/decoding.py +73 -0
- justdata/acoustic/eval_views.py +54 -0
- justdata/acoustic/evals.py +71 -0
- justdata/acoustic/filters.py +18 -0
- justdata/acoustic/frontends/__init__.py +37 -0
- justdata/acoustic/frontends/ast.py +116 -0
- justdata/acoustic/frontends/kaldi.py +34 -0
- justdata/acoustic/frontends/log.py +94 -0
- justdata/acoustic/frontends/mel.py +173 -0
- justdata/acoustic/frontends/mfcc.py +26 -0
- justdata/acoustic/frontends/pcen.py +26 -0
- justdata/acoustic/frontends/stft.py +174 -0
- justdata/acoustic/jax.py +23 -0
- justdata/acoustic/labels.py +169 -0
- justdata/acoustic/layouts.py +86 -0
- justdata/acoustic/metadata.py +152 -0
- justdata/acoustic/normalization.py +196 -0
- justdata/acoustic/pipelines.py +112 -0
- justdata/acoustic/postprocessing.py +328 -0
- justdata/acoustic/preprocessing.py +175 -0
- justdata/acoustic/presets.py +257 -0
- justdata/acoustic/registry.py +381 -0
- justdata/acoustic/resampling.py +218 -0
- justdata/acoustic/schema.py +51 -0
- justdata/acoustic/segment.py +369 -0
- justdata/acoustic/sources.py +503 -0
- justdata/acoustic/stages.py +59 -0
- justdata/acoustic/stats.py +50 -0
- justdata/acoustic/tasks.py +375 -0
- justdata/audio/__init__.py +20 -0
- justdata/core/__init__.py +74 -0
- justdata/core/adapters.py +46 -0
- justdata/core/augmentations.py +34 -0
- justdata/core/filters.py +94 -0
- justdata/core/finalization.py +173 -0
- justdata/core/label_mixing.py +129 -0
- justdata/core/loader.py +384 -0
- justdata/core/metadata.py +250 -0
- justdata/core/presets.py +155 -0
- justdata/core/registry.py +229 -0
- justdata/core/sources.py +87 -0
- justdata/core/stats.py +227 -0
- justdata/corruptions.py +52 -0
- justdata/py.typed +0 -0
- justdata/vision/__init__.py +17 -0
- justdata/vision/augmentations/__init__.py +31 -0
- justdata/vision/augmentations/auto.py +480 -0
- justdata/vision/augmentations/color.py +163 -0
- justdata/vision/augmentations/composed.py +156 -0
- justdata/vision/augmentations/geometric.py +302 -0
- justdata/vision/augmentations/mixing.py +232 -0
- justdata/vision/augmentations/registry.py +142 -0
- justdata/vision/corruptions/__init__.py +16 -0
- justdata/vision/corruptions/blur.py +65 -0
- justdata/vision/corruptions/digital.py +26 -0
- justdata/vision/corruptions/noise.py +20 -0
- justdata/vision/corruptions/registry.py +113 -0
- justdata/vision/corruptions/weather.py +100 -0
- justdata/vision/datasets.py +34 -0
- justdata/vision/encodings/__init__.py +1 -0
- justdata/vision/encodings/heatmaps.py +196 -0
- justdata/vision/minic.py +69 -0
- justdata/vision/pipelines.py +62 -0
- justdata/vision/presets.py +509 -0
- justdata/vision/sources.py +1080 -0
- justdata/vision/stages.py +271 -0
- justdata/vision/tasks/__init__.py +1 -0
- justdata/vision/tasks/classification.py +321 -0
- justdata/vision/tasks/depth.py +25 -0
- justdata/vision/tasks/segmentation.py +194 -0
- justdata/vision/transforms.py +113 -0
- justdata/vision/utils.py +741 -0
- justdata-1.0.0.dist-info/METADATA +860 -0
- justdata-1.0.0.dist-info/RECORD +106 -0
- justdata-1.0.0.dist-info/WHEEL +4 -0
- justdata-1.0.0.dist-info/licenses/LICENSE +23 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
from typing import Any, Dict
|
|
3
|
+
|
|
4
|
+
from justdata.core.presets import (
|
|
5
|
+
ResolvedPreset,
|
|
6
|
+
get_dataset_presets as _get_dataset_presets,
|
|
7
|
+
get_resolved_preset as _get_resolved_preset,
|
|
8
|
+
merge_with_presets as _merge_with_presets,
|
|
9
|
+
register_preset as _register_preset,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _normalization_contract(postproc_kwargs: Dict[str, Any]) -> Dict[str, Any]:
|
|
14
|
+
if not postproc_kwargs.get("normalize_image", True):
|
|
15
|
+
return {"kind": "none"}
|
|
16
|
+
|
|
17
|
+
normalization_mode = postproc_kwargs.get("normalization_mode", "mean_std")
|
|
18
|
+
if normalization_mode == "per_image":
|
|
19
|
+
return {"kind": "per_image", "per_channel": True}
|
|
20
|
+
if normalization_mode != "mean_std":
|
|
21
|
+
return {"kind": normalization_mode}
|
|
22
|
+
|
|
23
|
+
mean, std = postproc_kwargs.get(
|
|
24
|
+
"normalization_params",
|
|
25
|
+
((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
|
|
26
|
+
)
|
|
27
|
+
return {
|
|
28
|
+
"kind": "mean_std",
|
|
29
|
+
"mean": tuple(mean),
|
|
30
|
+
"std": tuple(std),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _with_model_input_contract(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
35
|
+
resolved = copy.deepcopy(config)
|
|
36
|
+
postproc_kwargs = resolved.get("postproc_kwargs", {})
|
|
37
|
+
image_size = postproc_kwargs.get("image_size")
|
|
38
|
+
permute_image = postproc_kwargs.get("permute_image", True)
|
|
39
|
+
layout = "bchw" if permute_image else "bhwc"
|
|
40
|
+
static_shape = None
|
|
41
|
+
if image_size is not None:
|
|
42
|
+
static_shape = (
|
|
43
|
+
(3, image_size, image_size)
|
|
44
|
+
if permute_image
|
|
45
|
+
else (image_size, image_size, 3)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
contract = {
|
|
49
|
+
"output_key": "image",
|
|
50
|
+
"layout": layout,
|
|
51
|
+
"dtype": "float32",
|
|
52
|
+
"static_shape": static_shape,
|
|
53
|
+
"normalization": _normalization_contract(postproc_kwargs),
|
|
54
|
+
}
|
|
55
|
+
contract.update(resolved.get("model_input", {}))
|
|
56
|
+
resolved["model_input"] = contract
|
|
57
|
+
return resolved
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def register_preset(dataset: str, config: Dict[str, Any]):
|
|
61
|
+
_register_preset(dataset, _with_model_input_contract(config), modality="vision")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_dataset_presets(dataset: str) -> Dict[str, Any]:
|
|
65
|
+
return _get_dataset_presets(dataset, modality="vision")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_resolved_preset(dataset: str) -> ResolvedPreset:
|
|
69
|
+
return _get_resolved_preset(dataset, modality="vision")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# ImageNet normalization stats (shared across ImageNet presets)
|
|
73
|
+
_IMAGENET_MEAN = (0.485, 0.456, 0.406)
|
|
74
|
+
_IMAGENET_STD = (0.229, 0.224, 0.225)
|
|
75
|
+
_IMAGENET_NORM = (_IMAGENET_MEAN, _IMAGENET_STD)
|
|
76
|
+
|
|
77
|
+
_CIFAR10_NORM = ((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010))
|
|
78
|
+
_CIFAR100_NORM = ((0.5071, 0.4867, 0.4408), (0.2675, 0.2565, 0.2761))
|
|
79
|
+
|
|
80
|
+
# CIFAR-10 / CIFAR-100
|
|
81
|
+
# Modern branch: TrivialAugment, zero-padding crop.
|
|
82
|
+
# RandomCrop(32, padding=4, padding_mode='zeros') -> RandomHorizontalFlip
|
|
83
|
+
register_preset(
|
|
84
|
+
"cifar100",
|
|
85
|
+
{
|
|
86
|
+
"preproc_kwargs": {},
|
|
87
|
+
"aug_kwargs": {
|
|
88
|
+
"image_size": 32,
|
|
89
|
+
"crop_type": "random_pad",
|
|
90
|
+
"padding": 4,
|
|
91
|
+
"pad_mode": "CONSTANT",
|
|
92
|
+
"augment_type": "trivial_augment_wide",
|
|
93
|
+
"ra_kwargs": {
|
|
94
|
+
"num_layers": 2,
|
|
95
|
+
"magnitude": 9.0,
|
|
96
|
+
"cutout_const": 14.0,
|
|
97
|
+
"translate_const": 14.0,
|
|
98
|
+
},
|
|
99
|
+
"gc_kwargs": {"size": 32, "scale": (0.32, 1.0)},
|
|
100
|
+
"lc_kwargs": {"size": 16, "scale": (0.05, 0.32)},
|
|
101
|
+
},
|
|
102
|
+
"laug_kwargs": {
|
|
103
|
+
"mixup_alpha": 0.8,
|
|
104
|
+
"cutmix_alpha": 1.0,
|
|
105
|
+
"prob": 1.0,
|
|
106
|
+
"switch_prob": 0.5,
|
|
107
|
+
"random_erasing_prob": 0.25,
|
|
108
|
+
},
|
|
109
|
+
"postproc_kwargs": {
|
|
110
|
+
"image_size": 32,
|
|
111
|
+
"val_resize_size": None,
|
|
112
|
+
"normalization_params": _CIFAR100_NORM,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
register_preset(
|
|
118
|
+
"cifar",
|
|
119
|
+
{
|
|
120
|
+
"preproc_kwargs": {},
|
|
121
|
+
"aug_kwargs": {
|
|
122
|
+
"image_size": 32,
|
|
123
|
+
"crop_type": "random_pad",
|
|
124
|
+
"padding": 4,
|
|
125
|
+
"pad_mode": "CONSTANT",
|
|
126
|
+
"augment_type": "trivial_augment_wide",
|
|
127
|
+
"ra_kwargs": {
|
|
128
|
+
"num_layers": 2,
|
|
129
|
+
"magnitude": 9.0,
|
|
130
|
+
"cutout_const": 14.0,
|
|
131
|
+
"translate_const": 14.0,
|
|
132
|
+
},
|
|
133
|
+
"gc_kwargs": {"size": 32, "scale": (0.32, 1.0)},
|
|
134
|
+
"lc_kwargs": {"size": 16, "scale": (0.05, 0.32)},
|
|
135
|
+
},
|
|
136
|
+
"laug_kwargs": {
|
|
137
|
+
"mixup_alpha": 0.8,
|
|
138
|
+
"cutmix_alpha": 1.0,
|
|
139
|
+
"prob": 1.0,
|
|
140
|
+
"switch_prob": 0.5,
|
|
141
|
+
"random_erasing_prob": 0.25,
|
|
142
|
+
},
|
|
143
|
+
"postproc_kwargs": {
|
|
144
|
+
"image_size": 32,
|
|
145
|
+
"val_resize_size": None,
|
|
146
|
+
"normalization_params": _CIFAR10_NORM,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# KITTI road segmentation. Keep this separate from the ImageNet classification
|
|
152
|
+
# default because segmentation augmentation accepts a deliberately smaller API.
|
|
153
|
+
register_preset(
|
|
154
|
+
"kitti_road",
|
|
155
|
+
{
|
|
156
|
+
"preproc_kwargs": {},
|
|
157
|
+
"aug_kwargs": {
|
|
158
|
+
"image_size": 224,
|
|
159
|
+
"crop_type": "random_resized",
|
|
160
|
+
"augment_type": "rand_augment",
|
|
161
|
+
},
|
|
162
|
+
"laug_kwargs": {},
|
|
163
|
+
"postproc_kwargs": {
|
|
164
|
+
"image_size": 224,
|
|
165
|
+
"normalization_params": _IMAGENET_NORM,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# ImageNet default (ViT / ConvNeXt modern recipe)
|
|
171
|
+
# RandAugment(n=2, m=9), bicubic interpolation, 0.875 crop ratio validation.
|
|
172
|
+
register_preset(
|
|
173
|
+
"_default",
|
|
174
|
+
{
|
|
175
|
+
"preproc_kwargs": {},
|
|
176
|
+
"aug_kwargs": {
|
|
177
|
+
"image_size": 224,
|
|
178
|
+
"interpolation": "bicubic",
|
|
179
|
+
"augment_type": "rand_augment",
|
|
180
|
+
"ra_kwargs": {
|
|
181
|
+
"num_layers": 2,
|
|
182
|
+
"magnitude": 9.0,
|
|
183
|
+
"cutout_const": 40.0,
|
|
184
|
+
"translate_const": 101.0,
|
|
185
|
+
},
|
|
186
|
+
"gc_kwargs": {"size": 224, "scale": (0.32, 1.0)},
|
|
187
|
+
"lc_kwargs": {"size": 96, "scale": (0.05, 0.32)},
|
|
188
|
+
},
|
|
189
|
+
"laug_kwargs": {
|
|
190
|
+
"mixup_alpha": 0.8,
|
|
191
|
+
"cutmix_alpha": 1.0,
|
|
192
|
+
"prob": 1.0,
|
|
193
|
+
"switch_prob": 0.5,
|
|
194
|
+
"random_erasing_prob": 0.25,
|
|
195
|
+
},
|
|
196
|
+
"postproc_kwargs": {
|
|
197
|
+
"image_size": 224,
|
|
198
|
+
"normalization_params": _IMAGENET_NORM,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# ImageNet — Legacy ResNet branch (ColorJitter, no RandAugment)
|
|
204
|
+
# ColorJitter(brightness=0.4, contrast=0.4, saturation=0.4, hue=0.1)
|
|
205
|
+
register_preset(
|
|
206
|
+
"imagenet_resnet",
|
|
207
|
+
{
|
|
208
|
+
"preproc_kwargs": {},
|
|
209
|
+
"aug_kwargs": {
|
|
210
|
+
"image_size": 224,
|
|
211
|
+
"interpolation": "bicubic",
|
|
212
|
+
"augment_type": "color_jitter",
|
|
213
|
+
"cj_kwargs": {
|
|
214
|
+
"brightness": 0.4,
|
|
215
|
+
"contrast": 0.4,
|
|
216
|
+
"saturation": 0.4,
|
|
217
|
+
"hue": 0.1,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
"laug_kwargs": {
|
|
221
|
+
"mixup_alpha": 0.2,
|
|
222
|
+
"cutmix_alpha": 1.0,
|
|
223
|
+
"prob": 1.0,
|
|
224
|
+
"switch_prob": 0.5,
|
|
225
|
+
"random_erasing_prob": 0.25,
|
|
226
|
+
"bce_target": False,
|
|
227
|
+
},
|
|
228
|
+
"postproc_kwargs": {
|
|
229
|
+
"image_size": 224,
|
|
230
|
+
"normalization_params": _IMAGENET_NORM,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# RSB A1 — Heavy (ResNet-152/200, 600 epochs, BCE loss)
|
|
236
|
+
register_preset(
|
|
237
|
+
"imagenet_a1",
|
|
238
|
+
{
|
|
239
|
+
"preproc_kwargs": {},
|
|
240
|
+
"aug_kwargs": {
|
|
241
|
+
"image_size": 224,
|
|
242
|
+
"interpolation": "bicubic",
|
|
243
|
+
"augment_type": "rand_augment",
|
|
244
|
+
"ra_kwargs": {
|
|
245
|
+
"num_layers": 2,
|
|
246
|
+
"magnitude": 7.0,
|
|
247
|
+
"cutout_const": 40.0,
|
|
248
|
+
"translate_const": 101.0,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
"laug_kwargs": {
|
|
252
|
+
"mixup_alpha": 0.2,
|
|
253
|
+
"cutmix_alpha": 1.0,
|
|
254
|
+
"prob": 1.0,
|
|
255
|
+
"switch_prob": 0.5,
|
|
256
|
+
"random_erasing_prob": 0.35,
|
|
257
|
+
},
|
|
258
|
+
"postproc_kwargs": {
|
|
259
|
+
"image_size": 224,
|
|
260
|
+
# crop_pct=1.0 -> no short-side resize + center crop, just resize
|
|
261
|
+
"val_resize_size": None,
|
|
262
|
+
"normalization_params": _IMAGENET_NORM,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# RSB A2 — Moderate (ResNet-50, 300 epochs, BCE loss)
|
|
268
|
+
register_preset(
|
|
269
|
+
"imagenet_a2",
|
|
270
|
+
{
|
|
271
|
+
"preproc_kwargs": {},
|
|
272
|
+
"aug_kwargs": {
|
|
273
|
+
"image_size": 224,
|
|
274
|
+
"interpolation": "bicubic",
|
|
275
|
+
"augment_type": "rand_augment",
|
|
276
|
+
"ra_kwargs": {
|
|
277
|
+
"num_layers": 2,
|
|
278
|
+
"magnitude": 6.0,
|
|
279
|
+
"cutout_const": 40.0,
|
|
280
|
+
"translate_const": 101.0,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
"laug_kwargs": {
|
|
284
|
+
"mixup_alpha": 0.2,
|
|
285
|
+
"cutmix_alpha": 1.0,
|
|
286
|
+
"prob": 1.0,
|
|
287
|
+
"switch_prob": 0.5,
|
|
288
|
+
"random_erasing_prob": 0.25,
|
|
289
|
+
},
|
|
290
|
+
"postproc_kwargs": {
|
|
291
|
+
"image_size": 224,
|
|
292
|
+
# crop_pct=1.0 -> no short-side resize + center crop, just resize
|
|
293
|
+
"val_resize_size": None,
|
|
294
|
+
"normalization_params": _IMAGENET_NORM,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
# RSB A3 — Light (ResNet-50 fast / ResNet-18, 100 epochs, CE loss)
|
|
300
|
+
# FixRes: train at 160, validate at 224 (resize to ~236, center crop 224).
|
|
301
|
+
register_preset(
|
|
302
|
+
"imagenet_a3",
|
|
303
|
+
{
|
|
304
|
+
"preproc_kwargs": {},
|
|
305
|
+
"aug_kwargs": {
|
|
306
|
+
"image_size": 160,
|
|
307
|
+
"interpolation": "bicubic",
|
|
308
|
+
"augment_type": "rand_augment",
|
|
309
|
+
"ra_kwargs": {
|
|
310
|
+
"num_layers": 2,
|
|
311
|
+
"magnitude": 6.0,
|
|
312
|
+
"cutout_const": 40.0,
|
|
313
|
+
"translate_const": 72.0,
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
"laug_kwargs": {
|
|
317
|
+
"mixup_alpha": 0.1,
|
|
318
|
+
"cutmix_alpha": 1.0,
|
|
319
|
+
"prob": 1.0,
|
|
320
|
+
"switch_prob": 0.5,
|
|
321
|
+
"random_erasing_prob": 0.0,
|
|
322
|
+
"bce_target": False,
|
|
323
|
+
},
|
|
324
|
+
"postproc_kwargs": {
|
|
325
|
+
"image_size": 224,
|
|
326
|
+
# FixRes: train at 160, validate at 224 (resize to 236, center crop 224)
|
|
327
|
+
"train_image_size": 160,
|
|
328
|
+
"val_resize_size": 236,
|
|
329
|
+
"normalization_params": _IMAGENET_NORM,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
# DINOv2 Self-Supervised Learning
|
|
335
|
+
# Asymmetric multi-crop with per-crop blur/solarize probabilities.
|
|
336
|
+
register_preset(
|
|
337
|
+
"dinov2",
|
|
338
|
+
{
|
|
339
|
+
"preproc_kwargs": {},
|
|
340
|
+
"aug_kwargs": {
|
|
341
|
+
"image_size": 224,
|
|
342
|
+
"mode": "ssl",
|
|
343
|
+
"n_global_crops": 2,
|
|
344
|
+
"n_local_crops": 8,
|
|
345
|
+
"gc_kwargs": {
|
|
346
|
+
"size": 224,
|
|
347
|
+
"scale": (0.32, 1.0),
|
|
348
|
+
"brightness": 0.4,
|
|
349
|
+
"contrast": 0.4,
|
|
350
|
+
"saturation": 0.2,
|
|
351
|
+
"hue": 0.1,
|
|
352
|
+
"p_color_jitter": 0.8,
|
|
353
|
+
"p_grayscale": 0.2,
|
|
354
|
+
# Per-crop asymmetry (DINOv2):
|
|
355
|
+
# crop 0: blur=1.0, solar=0.0
|
|
356
|
+
# crop 1: blur=0.1, solar=0.2
|
|
357
|
+
"p_gaussian_blur": (1.0, 0.1),
|
|
358
|
+
"p_solarize": (0.0, 0.2),
|
|
359
|
+
},
|
|
360
|
+
"lc_kwargs": {
|
|
361
|
+
"size": 96,
|
|
362
|
+
"scale": (0.05, 0.32),
|
|
363
|
+
"brightness": 0.4,
|
|
364
|
+
"contrast": 0.4,
|
|
365
|
+
"saturation": 0.2,
|
|
366
|
+
"hue": 0.1,
|
|
367
|
+
"p_color_jitter": 0.8,
|
|
368
|
+
"p_grayscale": 0.2,
|
|
369
|
+
"p_gaussian_blur": 0.5,
|
|
370
|
+
"p_solarize": 0.0,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
"laug_kwargs": {},
|
|
374
|
+
"postproc_kwargs": {
|
|
375
|
+
"image_size": 224,
|
|
376
|
+
"normalization_params": _IMAGENET_NORM,
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def _register_wilds_preset(
|
|
383
|
+
dataset: str,
|
|
384
|
+
image_size: int,
|
|
385
|
+
*,
|
|
386
|
+
aug_kwargs: Dict[str, Any] | None = None,
|
|
387
|
+
laug_kwargs: Dict[str, Any] | None = None,
|
|
388
|
+
postproc_kwargs: Dict[str, Any] | None = None,
|
|
389
|
+
):
|
|
390
|
+
resolved_aug_kwargs = {
|
|
391
|
+
"enable": False,
|
|
392
|
+
"image_size": image_size,
|
|
393
|
+
}
|
|
394
|
+
if aug_kwargs is not None:
|
|
395
|
+
resolved_aug_kwargs.update(aug_kwargs)
|
|
396
|
+
|
|
397
|
+
resolved_laug_kwargs = {
|
|
398
|
+
"enable": False,
|
|
399
|
+
}
|
|
400
|
+
if laug_kwargs is not None:
|
|
401
|
+
resolved_laug_kwargs.update(laug_kwargs)
|
|
402
|
+
|
|
403
|
+
resolved_postproc_kwargs = {
|
|
404
|
+
"image_size": image_size,
|
|
405
|
+
"val_resize_size": None,
|
|
406
|
+
"normalization_params": _IMAGENET_NORM,
|
|
407
|
+
}
|
|
408
|
+
if postproc_kwargs is not None:
|
|
409
|
+
resolved_postproc_kwargs.update(postproc_kwargs)
|
|
410
|
+
if (
|
|
411
|
+
postproc_kwargs.get("normalization_mode") == "per_image"
|
|
412
|
+
and "normalization_params" not in postproc_kwargs
|
|
413
|
+
):
|
|
414
|
+
resolved_postproc_kwargs.pop("normalization_params", None)
|
|
415
|
+
|
|
416
|
+
register_preset(
|
|
417
|
+
dataset,
|
|
418
|
+
{
|
|
419
|
+
"preproc_kwargs": {},
|
|
420
|
+
"aug_kwargs": resolved_aug_kwargs,
|
|
421
|
+
"laug_kwargs": resolved_laug_kwargs,
|
|
422
|
+
"postproc_kwargs": resolved_postproc_kwargs,
|
|
423
|
+
},
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
_register_wilds_preset("wilds:camelyon17", 96)
|
|
428
|
+
_register_wilds_preset("wilds:fmow", 224)
|
|
429
|
+
_register_wilds_preset("wilds:iwildcam", 448)
|
|
430
|
+
_register_wilds_preset(
|
|
431
|
+
"wilds:rxrx1",
|
|
432
|
+
256,
|
|
433
|
+
aug_kwargs={
|
|
434
|
+
"enable": True,
|
|
435
|
+
"crop_type": "random_rot90_hflip",
|
|
436
|
+
"augment_type": "none",
|
|
437
|
+
},
|
|
438
|
+
postproc_kwargs={
|
|
439
|
+
"normalization_mode": "per_image",
|
|
440
|
+
},
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
_register_wilds_preset(
|
|
444
|
+
"wilds:camelyon17_strong",
|
|
445
|
+
96,
|
|
446
|
+
aug_kwargs={
|
|
447
|
+
"enable": True,
|
|
448
|
+
"crop_type": "random_rot90_hflip",
|
|
449
|
+
"augment_type": "color_jitter",
|
|
450
|
+
"cj_kwargs": {
|
|
451
|
+
"brightness": 0.2,
|
|
452
|
+
"contrast": 0.2,
|
|
453
|
+
"saturation": 0.2,
|
|
454
|
+
"hue": 0.05,
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
)
|
|
458
|
+
_register_wilds_preset(
|
|
459
|
+
"wilds:fmow_strong",
|
|
460
|
+
224,
|
|
461
|
+
aug_kwargs={
|
|
462
|
+
"enable": True,
|
|
463
|
+
"crop_type": "resize_random_hflip",
|
|
464
|
+
"augment_type": "rand_augment",
|
|
465
|
+
"ra_kwargs": {
|
|
466
|
+
"num_layers": 2,
|
|
467
|
+
"magnitude": 9.0,
|
|
468
|
+
"cutout_const": 40.0,
|
|
469
|
+
"translate_const": 101.0,
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
)
|
|
473
|
+
_register_wilds_preset(
|
|
474
|
+
"wilds:iwildcam_strong",
|
|
475
|
+
448,
|
|
476
|
+
aug_kwargs={
|
|
477
|
+
"enable": True,
|
|
478
|
+
"crop_type": "resize_random_hflip",
|
|
479
|
+
"augment_type": "rand_augment",
|
|
480
|
+
"ra_kwargs": {
|
|
481
|
+
"num_layers": 2,
|
|
482
|
+
"magnitude": 9.0,
|
|
483
|
+
"cutout_const": 80.0,
|
|
484
|
+
"translate_const": 203.0,
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
)
|
|
488
|
+
_register_wilds_preset(
|
|
489
|
+
"wilds:rxrx1_strong",
|
|
490
|
+
256,
|
|
491
|
+
aug_kwargs={
|
|
492
|
+
"enable": True,
|
|
493
|
+
"crop_type": "random_rot90_hflip",
|
|
494
|
+
"augment_type": "none",
|
|
495
|
+
},
|
|
496
|
+
laug_kwargs={
|
|
497
|
+
"enable": True,
|
|
498
|
+
"mixup_alpha": 0.0,
|
|
499
|
+
"cutmix_alpha": 0.0,
|
|
500
|
+
"random_erasing_prob": 0.25,
|
|
501
|
+
},
|
|
502
|
+
postproc_kwargs={
|
|
503
|
+
"normalization_mode": "per_image",
|
|
504
|
+
},
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
def merge_with_presets(dataset: str, user_kwargs: Dict[str, Any]) -> Dict[str, Any]:
|
|
509
|
+
return _merge_with_presets(dataset, user_kwargs, modality="vision")
|