justdata 1.2.1__tar.gz → 1.3.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.
- {justdata-1.2.1 → justdata-1.3.0}/PKG-INFO +29 -5
- {justdata-1.2.1 → justdata-1.3.0}/README.md +28 -4
- {justdata-1.2.1 → justdata-1.3.0}/pyproject.toml +1 -1
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/__init__.py +1 -1
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/execution.py +5 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/geometry.py +143 -27
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/pipelines.py +2 -2
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/stages.py +2 -2
- {justdata-1.2.1 → justdata-1.3.0}/LICENSE +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/_dcase.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/_manifests.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/_random.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/_signal.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/adapters.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/_common.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/batch.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/configs.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/patchout.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/spectrogram.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/augment/waveform.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/batching.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/channel.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/ast.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/ced.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/efficientat.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/panns.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/compat/passt.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/configs.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/codec.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/datasets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/device.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/dynamics.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/filters.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/noise.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/registry.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/reverb.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/corruptions/timefreq.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/datasets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/dcase2025.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/decoding.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/eval_views.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/evals.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/filters.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/ast.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/kaldi.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/log.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/mel.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/mfcc.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/pcen.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/frontends/stft.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/jax.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/labels.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/layouts.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/metadata.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/normalization.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/pipelines.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/postprocessing.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/preprocessing.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/presets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/registry.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/resampling.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/schema.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/segment.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/sources.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/stages.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/stats.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/acoustic/tasks.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/audio/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/_records.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/adapters.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/augmentations.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/cache.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/config_resolution.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/executed_config.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/filters.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/finalization.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/inventory.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/label_mixing.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/loader.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/metadata.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/presets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/registry.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/replay.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/sources.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/core/stats.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/corruptions.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/py.typed +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/auto.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/color.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/composed.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/geometric.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/mixing.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/augmentations/registry.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/blur.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/digital.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/noise.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/registry.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/standard.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/corruptions/weather.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/datasets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/encodings/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/encodings/heatmaps.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/encodings/panoptic_targets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/encodings/semantic_targets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/minic.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/presets.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/sources.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/tasks/__init__.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/tasks/classification.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/tasks/depth.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/tasks/panoptic.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/tasks/segmentation.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/transforms.py +0 -0
- {justdata-1.2.1 → justdata-1.3.0}/src/justdata/vision/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: justdata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A TensorFlow-native data pipeline library with a modality-neutral core and first-class computer vision and acoustic recipes
|
|
5
5
|
Author: clementpoiret
|
|
6
6
|
Author-email: clementpoiret <clement@linux.com>
|
|
@@ -546,7 +546,9 @@ For semantic segmentation with replayable geometry, select `vision/segmentation`
|
|
|
546
546
|
`geometry_kwargs`. It supports paired aspect-preserving training resize and crops, longer-side evaluation caps,
|
|
547
547
|
independent RGB/ignore padding, per-pixel validity, and original-coordinate score restoration. See
|
|
548
548
|
[the dense geometry contract](docs/vision.md#12-replayable-dense-segmentation) for configuration, record fields, replay,
|
|
549
|
-
and batching requirements.
|
|
549
|
+
and batching requirements. For ordered image/mask file lists without a registered source,
|
|
550
|
+
`justdata.vision.geometry.dense_views_from_files` builds the same views with explicit per-example seeds in a parallel,
|
|
551
|
+
order-preserving `tf.data` map.
|
|
550
552
|
|
|
551
553
|
For instance-aware labels, select `vision/panoptic_segmentation` with a segment-ID map and category table. It preserves
|
|
552
554
|
thing instances, merges stuff by category, and excludes crowd pixels from panoptic supervision. The
|
|
@@ -1094,14 +1096,36 @@ Replay prefetches after skipping committed batches and defaults to one batch.
|
|
|
1094
1096
|
When another framework uses the accelerator, configure TensorFlow before creating tensors or datasets:
|
|
1095
1097
|
|
|
1096
1098
|
```python
|
|
1099
|
+
import jax
|
|
1100
|
+
|
|
1101
|
+
jax.devices() # initialize JAX's GPU backend before TensorFlow is imported
|
|
1102
|
+
|
|
1097
1103
|
from justdata.core import configure_tensorflow_cpu
|
|
1098
1104
|
|
|
1099
1105
|
device_report = configure_tensorflow_cpu(intra_op_threads=1, inter_op_threads=1)
|
|
1100
1106
|
assert device_report["logical_gpus"] == []
|
|
1101
1107
|
```
|
|
1102
1108
|
|
|
1103
|
-
The report includes physical and logical device names and process thread settings. The helper raises if the
|
|
1104
|
-
initialized too early for the requested change. Core, vision, acoustic, and audio imports
|
|
1109
|
+
The report includes physical and logical device names and process thread settings. The helper raises if the TensorFlow
|
|
1110
|
+
runtime has initialized too early for the requested change. Core, vision, acoustic, and audio imports do not initialize
|
|
1111
|
+
it, so the helper can run after them.
|
|
1112
|
+
|
|
1113
|
+
Those imports do import TensorFlow. On Linux, the CUDA-enabled `tensorflow` wheel then exposes stubs for its CUDA
|
|
1114
|
+
libraries (CUDA 12 as of TensorFlow 2.21) to the whole process. A framework built for another CUDA version that
|
|
1115
|
+
initializes its GPU backend afterwards can bind to those stubs: JAX with its CUDA 13 plugin reports an outdated cuBLAS
|
|
1116
|
+
and falls back to the CPU. Hiding TensorFlow's GPUs does not prevent this. Either initialize the other framework's
|
|
1117
|
+
backend before the first TensorFlow import, as above (`import jax` alone is not enough), or install `tensorflow-cpu`,
|
|
1118
|
+
which exports no CUDA symbols, in place of `tensorflow`. With uv, on Linux x86_64:
|
|
1119
|
+
|
|
1120
|
+
```toml
|
|
1121
|
+
[project]
|
|
1122
|
+
dependencies = ["justdata", "tensorflow-cpu"]
|
|
1123
|
+
|
|
1124
|
+
[tool.uv]
|
|
1125
|
+
exclude-dependencies = ["tensorflow"]
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
Set `JAX_PLATFORMS=cuda` to make a JAX fallback to the CPU an error rather than a warning.
|
|
1105
1129
|
|
|
1106
1130
|
`CachePolicy` enables identity-checked file caches on the existing preprocessing and model-input cache stages. The cache
|
|
1107
1131
|
path is a directory whose parent exists. The input identity must cover ordered content. `load_inventory` binds its
|
|
@@ -1306,7 +1330,7 @@ package-support jobs pass. Build artifacts are retained for one week. Tag pipeli
|
|
|
1306
1330
|
to complete a release.
|
|
1307
1331
|
|
|
1308
1332
|
Before tagging, update `pyproject.toml`, `src/justdata/__init__.py`, and `CHANGELOG.md`, then run `uv lock`. Push a tag
|
|
1309
|
-
matching the package version, with an optional `v` prefix (for example, `v1.
|
|
1333
|
+
matching the package version, with an optional `v` prefix (for example, `v1.3.0` or `1.3.0`). Publishing rejects tags
|
|
1310
1334
|
that disagree with either version declaration. Branch pipelines build artifacts without publishing.
|
|
1311
1335
|
|
|
1312
1336
|
Configure a [PyPI GitLab trusted publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/) for the
|
|
@@ -503,7 +503,9 @@ For semantic segmentation with replayable geometry, select `vision/segmentation`
|
|
|
503
503
|
`geometry_kwargs`. It supports paired aspect-preserving training resize and crops, longer-side evaluation caps,
|
|
504
504
|
independent RGB/ignore padding, per-pixel validity, and original-coordinate score restoration. See
|
|
505
505
|
[the dense geometry contract](docs/vision.md#12-replayable-dense-segmentation) for configuration, record fields, replay,
|
|
506
|
-
and batching requirements.
|
|
506
|
+
and batching requirements. For ordered image/mask file lists without a registered source,
|
|
507
|
+
`justdata.vision.geometry.dense_views_from_files` builds the same views with explicit per-example seeds in a parallel,
|
|
508
|
+
order-preserving `tf.data` map.
|
|
507
509
|
|
|
508
510
|
For instance-aware labels, select `vision/panoptic_segmentation` with a segment-ID map and category table. It preserves
|
|
509
511
|
thing instances, merges stuff by category, and excludes crowd pixels from panoptic supervision. The
|
|
@@ -1051,14 +1053,36 @@ Replay prefetches after skipping committed batches and defaults to one batch.
|
|
|
1051
1053
|
When another framework uses the accelerator, configure TensorFlow before creating tensors or datasets:
|
|
1052
1054
|
|
|
1053
1055
|
```python
|
|
1056
|
+
import jax
|
|
1057
|
+
|
|
1058
|
+
jax.devices() # initialize JAX's GPU backend before TensorFlow is imported
|
|
1059
|
+
|
|
1054
1060
|
from justdata.core import configure_tensorflow_cpu
|
|
1055
1061
|
|
|
1056
1062
|
device_report = configure_tensorflow_cpu(intra_op_threads=1, inter_op_threads=1)
|
|
1057
1063
|
assert device_report["logical_gpus"] == []
|
|
1058
1064
|
```
|
|
1059
1065
|
|
|
1060
|
-
The report includes physical and logical device names and process thread settings. The helper raises if the
|
|
1061
|
-
initialized too early for the requested change. Core, vision, acoustic, and audio imports
|
|
1066
|
+
The report includes physical and logical device names and process thread settings. The helper raises if the TensorFlow
|
|
1067
|
+
runtime has initialized too early for the requested change. Core, vision, acoustic, and audio imports do not initialize
|
|
1068
|
+
it, so the helper can run after them.
|
|
1069
|
+
|
|
1070
|
+
Those imports do import TensorFlow. On Linux, the CUDA-enabled `tensorflow` wheel then exposes stubs for its CUDA
|
|
1071
|
+
libraries (CUDA 12 as of TensorFlow 2.21) to the whole process. A framework built for another CUDA version that
|
|
1072
|
+
initializes its GPU backend afterwards can bind to those stubs: JAX with its CUDA 13 plugin reports an outdated cuBLAS
|
|
1073
|
+
and falls back to the CPU. Hiding TensorFlow's GPUs does not prevent this. Either initialize the other framework's
|
|
1074
|
+
backend before the first TensorFlow import, as above (`import jax` alone is not enough), or install `tensorflow-cpu`,
|
|
1075
|
+
which exports no CUDA symbols, in place of `tensorflow`. With uv, on Linux x86_64:
|
|
1076
|
+
|
|
1077
|
+
```toml
|
|
1078
|
+
[project]
|
|
1079
|
+
dependencies = ["justdata", "tensorflow-cpu"]
|
|
1080
|
+
|
|
1081
|
+
[tool.uv]
|
|
1082
|
+
exclude-dependencies = ["tensorflow"]
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
Set `JAX_PLATFORMS=cuda` to make a JAX fallback to the CPU an error rather than a warning.
|
|
1062
1086
|
|
|
1063
1087
|
`CachePolicy` enables identity-checked file caches on the existing preprocessing and model-input cache stages. The cache
|
|
1064
1088
|
path is a directory whose parent exists. The input identity must cover ordered content. `load_inventory` binds its
|
|
@@ -1263,7 +1287,7 @@ package-support jobs pass. Build artifacts are retained for one week. Tag pipeli
|
|
|
1263
1287
|
to complete a release.
|
|
1264
1288
|
|
|
1265
1289
|
Before tagging, update `pyproject.toml`, `src/justdata/__init__.py`, and `CHANGELOG.md`, then run `uv lock`. Push a tag
|
|
1266
|
-
matching the package version, with an optional `v` prefix (for example, `v1.
|
|
1290
|
+
matching the package version, with an optional `v` prefix (for example, `v1.3.0` or `1.3.0`). Publishing rejects tags
|
|
1267
1291
|
that disagree with either version declaration. Branch pipelines build artifacts without publishing.
|
|
1268
1292
|
|
|
1269
1293
|
Configure a [PyPI GitLab trusted publisher](https://docs.pypi.org/trusted-publishers/adding-a-publisher/) for the
|
|
@@ -14,6 +14,11 @@ def configure_tensorflow_cpu(
|
|
|
14
14
|
|
|
15
15
|
Call before constructing tensors, datasets, or invoking other TensorFlow
|
|
16
16
|
operations. A runtime that was initialized too early raises RuntimeError.
|
|
17
|
+
|
|
18
|
+
Hiding GPUs does not isolate TensorFlow's CUDA libraries. With the
|
|
19
|
+
CUDA-enabled ``tensorflow`` wheel, another framework must initialize its
|
|
20
|
+
GPU backend before TensorFlow is first imported; ``tensorflow-cpu`` has no
|
|
21
|
+
such ordering requirement.
|
|
17
22
|
"""
|
|
18
23
|
for name, value in (
|
|
19
24
|
("intra_op_threads", intra_op_threads),
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"""Versioned, paired dense geometry in HWC coordinates.
|
|
2
2
|
|
|
3
3
|
Records are dictionaries of numeric tensors, suitable for tf.data, NumPy storage,
|
|
4
|
-
and replay without a random generator.
|
|
4
|
+
and replay without a random generator. Both versions use half-pixel resize centers,
|
|
5
5
|
bilinear RGB sampling, nearest categorical sampling, and bottom/right padding.
|
|
6
|
+
Version 1 resamples RGB over the whole resized frame before cropping; version 2,
|
|
7
|
+
used by new records, resamples only a crop that lies inside the resized frame.
|
|
6
8
|
"""
|
|
7
9
|
|
|
8
10
|
import math
|
|
11
|
+
import os
|
|
9
12
|
from dataclasses import asdict, dataclass
|
|
10
13
|
|
|
11
14
|
import tensorflow as tf
|
|
@@ -138,19 +141,32 @@ def _bottom_right(amount):
|
|
|
138
141
|
return tf.stack([0, amount[0], 0, amount[1]])
|
|
139
142
|
|
|
140
143
|
|
|
144
|
+
def _canonical_seed(seed):
|
|
145
|
+
"""Widen an int32 or int64 stateless seed of shape [2] to int64.
|
|
146
|
+
|
|
147
|
+
``stateless_split`` draws in the seed dtype, so equal int32 and int64 seed
|
|
148
|
+
values would otherwise produce different views.
|
|
149
|
+
"""
|
|
150
|
+
seed = tf.ensure_shape(tf.convert_to_tensor(seed), [2])
|
|
151
|
+
if seed.dtype not in (tf.int32, tf.int64):
|
|
152
|
+
raise TypeError("seed must have int32 or int64 dtype")
|
|
153
|
+
return tf.cast(seed, tf.int64)
|
|
154
|
+
|
|
155
|
+
|
|
141
156
|
def sample_dense_geometry(
|
|
142
157
|
original_size, config: DenseGeometryConfig, *, is_training, seed=None
|
|
143
158
|
):
|
|
144
|
-
"""Create a version-
|
|
159
|
+
"""Create a version-2 record; training requires an int32/int64 seed of shape [2].
|
|
160
|
+
|
|
161
|
+
Seeds are widened to int64 first, so equal values select the same view
|
|
162
|
+
whatever their dtype.
|
|
163
|
+
"""
|
|
145
164
|
original = tf.ensure_shape(tf.convert_to_tensor(original_size, tf.int32), [2])
|
|
146
165
|
tf.debugging.assert_positive(original, message="original_size must be positive")
|
|
147
166
|
if is_training:
|
|
148
167
|
if seed is None:
|
|
149
168
|
raise ValueError("training geometry requires a stateless seed")
|
|
150
|
-
|
|
151
|
-
if seed.dtype not in (tf.int32, tf.int64):
|
|
152
|
-
raise TypeError("seed must have int32 or int64 dtype")
|
|
153
|
-
seeds = tf.random.experimental.stateless_split(seed, 4)
|
|
169
|
+
seeds = tf.random.experimental.stateless_split(_canonical_seed(seed), 4)
|
|
154
170
|
if config.train_resize_range is not None:
|
|
155
171
|
low, high = config.train_resize_range
|
|
156
172
|
target = tf.random.stateless_uniform(
|
|
@@ -196,7 +212,7 @@ def sample_dense_geometry(
|
|
|
196
212
|
after = (config.patch_size - cropped % config.patch_size) % config.patch_size
|
|
197
213
|
input_size = cropped + after
|
|
198
214
|
return {
|
|
199
|
-
"version": tf.constant(
|
|
215
|
+
"version": tf.constant(2, tf.int32),
|
|
200
216
|
"original_size": original,
|
|
201
217
|
"resized_size": resized,
|
|
202
218
|
"crop_box": tf.stack([top, left, cropped[0], cropped[1]]),
|
|
@@ -207,7 +223,7 @@ def sample_dense_geometry(
|
|
|
207
223
|
"model_input_size": input_size,
|
|
208
224
|
"patch_size": tf.constant(config.patch_size, tf.int32),
|
|
209
225
|
"grid_size": input_size // config.patch_size,
|
|
210
|
-
# Numeric enum values are
|
|
226
|
+
# Numeric enum values are shared by versions 1 and 2, see docs/vision.md.
|
|
211
227
|
"image_interpolation": tf.constant(1, tf.int32),
|
|
212
228
|
"mask_interpolation": tf.constant(0, tf.int32),
|
|
213
229
|
"alignment": tf.constant(1, tf.int32),
|
|
@@ -224,7 +240,7 @@ def sample_dense_geometry(
|
|
|
224
240
|
def sample_panoptic_geometry(
|
|
225
241
|
original_size, config: PanopticGeometryConfig, *, void_value, is_training, seed=None
|
|
226
242
|
):
|
|
227
|
-
"""Sample version-
|
|
243
|
+
"""Sample version-2 geometry with a panoptic label contract."""
|
|
228
244
|
record = sample_dense_geometry(
|
|
229
245
|
original_size, _spatial_config(config), is_training=is_training, seed=seed
|
|
230
246
|
)
|
|
@@ -238,8 +254,8 @@ def _check_record(record):
|
|
|
238
254
|
record = tf.nest.map_structure(tf.convert_to_tensor, record)
|
|
239
255
|
record["version"] = tf.ensure_shape(record["version"], [])
|
|
240
256
|
tf.debugging.assert_equal(
|
|
241
|
-
record["version"],
|
|
242
|
-
|
|
257
|
+
(record["version"] == 1) | (record["version"] == 2),
|
|
258
|
+
True,
|
|
243
259
|
message="unsupported geometry version",
|
|
244
260
|
)
|
|
245
261
|
for key, value in (
|
|
@@ -307,12 +323,13 @@ def validate_dense_sample(sample, class_values, ignore_value):
|
|
|
307
323
|
return result
|
|
308
324
|
|
|
309
325
|
|
|
310
|
-
def _nearest(tensor, size):
|
|
326
|
+
def _nearest(tensor, size, start, stop):
|
|
327
|
+
"""Sample rows and columns ``[start, stop)`` of ``tensor`` resized to ``size``."""
|
|
311
328
|
# Gather directly so categorical int64 IDs never pass through float32.
|
|
312
329
|
indices = []
|
|
313
330
|
for axis in (0, 1):
|
|
314
331
|
length = tf.shape(tensor)[axis]
|
|
315
|
-
centers = tf.cast(tf.range(
|
|
332
|
+
centers = tf.cast(tf.range(start[axis], stop[axis]), tf.float64) + 0.5
|
|
316
333
|
scale = tf.cast(length, tf.float64) / tf.cast(size[axis], tf.float64)
|
|
317
334
|
nearest = tf.cast(tf.floor(centers * scale), tf.int32)
|
|
318
335
|
indices.append(tf.minimum(nearest, length - 1))
|
|
@@ -379,36 +396,71 @@ def replay_dense_geometry(sample, record):
|
|
|
379
396
|
return result | {"pixel_valid_mask": valid}
|
|
380
397
|
|
|
381
398
|
|
|
399
|
+
def _resample_rgb(image, record, start, stop):
|
|
400
|
+
"""Bilinearly resample rows and columns ``[start, stop)`` of the resized frame."""
|
|
401
|
+
scale = tf.cast(record["resized_size"], tf.float32) / tf.cast(
|
|
402
|
+
tf.shape(image)[:2], tf.float32
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
def triangle(antialias):
|
|
406
|
+
# The op behind antialiased tf.image.resize. Translating by -start
|
|
407
|
+
# computes only the window; over the whole frame it matches that resize.
|
|
408
|
+
return lambda: tf.raw_ops.ScaleAndTranslate(
|
|
409
|
+
images=image[None],
|
|
410
|
+
size=stop - start,
|
|
411
|
+
scale=scale,
|
|
412
|
+
translation=-tf.cast(start, tf.float32),
|
|
413
|
+
kernel_type="triangle",
|
|
414
|
+
antialias=antialias,
|
|
415
|
+
)[0]
|
|
416
|
+
|
|
417
|
+
return tf.cond(
|
|
418
|
+
record["image_antialias"],
|
|
419
|
+
triangle(True),
|
|
420
|
+
lambda: tf.cond(
|
|
421
|
+
record["version"] == 1,
|
|
422
|
+
lambda: _bilinear_scores(image, record["resized_size"]),
|
|
423
|
+
triangle(False),
|
|
424
|
+
),
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
|
|
382
428
|
def _replay_spatial(sample, record):
|
|
383
429
|
tf.debugging.assert_equal(
|
|
384
430
|
tf.shape(sample["image"])[:2],
|
|
385
431
|
record["original_size"],
|
|
386
432
|
message="replay requires original sample dimensions",
|
|
387
433
|
)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
)
|
|
434
|
+
resized = record["resized_size"]
|
|
435
|
+
origin, size = record["crop_box"][:2], record["crop_box"][2:]
|
|
436
|
+
before = record["pre_padding"][::2]
|
|
437
|
+
# Version 2 resamples only a crop inside the resized frame. Axes whose crop
|
|
438
|
+
# reaches padding, and all version-1 axes, keep the frame to pad from it.
|
|
439
|
+
window = (
|
|
440
|
+
(record["version"] == 2)
|
|
441
|
+
& (origin >= before)
|
|
442
|
+
& (origin + size <= before + resized)
|
|
397
443
|
)
|
|
444
|
+
start = tf.where(window, origin - before, 0)
|
|
445
|
+
stop = tf.where(window, start + size, resized)
|
|
446
|
+
pre_padding = tf.where(tf.repeat(window, 2), 0, record["pre_padding"])
|
|
447
|
+
offset = tf.where(window, 0, origin)
|
|
398
448
|
|
|
399
449
|
def crop_flip(tensor):
|
|
400
|
-
top, left
|
|
450
|
+
top, left = tf.unstack(offset)
|
|
451
|
+
height, width = tf.unstack(size)
|
|
401
452
|
tensor = tensor[top : top + height, left : left + width]
|
|
402
453
|
return tf.cond(
|
|
403
454
|
record["horizontal_flip"], lambda: tf.reverse(tensor, [1]), lambda: tensor
|
|
404
455
|
)
|
|
405
456
|
|
|
406
|
-
image =
|
|
457
|
+
image = _resample_rgb(tf.cast(sample["image"], tf.float32), record, start, stop)
|
|
458
|
+
image = _pad_rgb(image, pre_padding, record)
|
|
407
459
|
image = _pad_rgb(crop_flip(image), record["post_padding"], record)
|
|
408
460
|
|
|
409
461
|
def categorical(tensor, fill):
|
|
410
|
-
tensor = _nearest(tensor,
|
|
411
|
-
tensor = _constant_pad(tensor,
|
|
462
|
+
tensor = _nearest(tensor, resized, start, stop)
|
|
463
|
+
tensor = _constant_pad(tensor, pre_padding, fill)
|
|
412
464
|
return _constant_pad(crop_flip(tensor), record["post_padding"], fill)
|
|
413
465
|
|
|
414
466
|
support = categorical(tf.ones(record["original_size"], tf.bool), False)
|
|
@@ -416,6 +468,69 @@ def _replay_spatial(sample, record):
|
|
|
416
468
|
return result, categorical
|
|
417
469
|
|
|
418
470
|
|
|
471
|
+
_PNG_SIGNATURE_AND_HEADER_CHUNK = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR"
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def _read_mask_png(path):
|
|
475
|
+
contents = tf.io.read_file(path)
|
|
476
|
+
# decode_png rescales 16-bit samples, maps palettes through RGB, and also
|
|
477
|
+
# decodes JPEG data; each would silently rewrite class IDs.
|
|
478
|
+
tf.debugging.assert_equal(
|
|
479
|
+
(tf.strings.substr(contents, 0, 16) == _PNG_SIGNATURE_AND_HEADER_CHUNK)
|
|
480
|
+
& (tf.strings.substr(contents, 24, 2) == b"\x08\x00"),
|
|
481
|
+
True,
|
|
482
|
+
message="mask files must be 8-bit grayscale PNG",
|
|
483
|
+
)
|
|
484
|
+
return tf.io.decode_png(contents, channels=1)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def dense_views_from_files(
|
|
488
|
+
image_paths,
|
|
489
|
+
config: DenseGeometryConfig,
|
|
490
|
+
*,
|
|
491
|
+
mask_paths=None,
|
|
492
|
+
seeds=None,
|
|
493
|
+
num_parallel_calls=tf.data.AUTOTUNE,
|
|
494
|
+
):
|
|
495
|
+
"""Replay one dense view per image file, in input order, in parallel.
|
|
496
|
+
|
|
497
|
+
Images decode to RGB uint8 and optional masks from 8-bit grayscale PNG.
|
|
498
|
+
Element ``i`` equals ``replay_dense_geometry`` of the decoded sample with
|
|
499
|
+
the training record for ``seeds[i]`` (``[N, 2]`` int32 or int64), or with
|
|
500
|
+
the evaluation record when ``seeds`` is None. Set threading options on the
|
|
501
|
+
returned dataset to bound its CPU use.
|
|
502
|
+
"""
|
|
503
|
+
columns = {
|
|
504
|
+
"image": tf.constant([os.fspath(path) for path in image_paths], tf.string)
|
|
505
|
+
}
|
|
506
|
+
if mask_paths is not None:
|
|
507
|
+
columns["mask"] = tf.constant(
|
|
508
|
+
[os.fspath(path) for path in mask_paths], tf.string
|
|
509
|
+
)
|
|
510
|
+
if seeds is not None:
|
|
511
|
+
columns["seed"] = seeds
|
|
512
|
+
|
|
513
|
+
def view(column):
|
|
514
|
+
sample = {
|
|
515
|
+
"image": tf.io.decode_image(
|
|
516
|
+
tf.io.read_file(column["image"]), channels=3, expand_animations=False
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
if "mask" in column:
|
|
520
|
+
sample["mask"] = _read_mask_png(column["mask"])
|
|
521
|
+
record = sample_dense_geometry(
|
|
522
|
+
tf.shape(sample["image"])[:2],
|
|
523
|
+
config,
|
|
524
|
+
is_training=seeds is not None,
|
|
525
|
+
seed=column.get("seed"),
|
|
526
|
+
)
|
|
527
|
+
return replay_dense_geometry(sample, record)
|
|
528
|
+
|
|
529
|
+
return tf.data.Dataset.from_tensor_slices(columns).map(
|
|
530
|
+
view, num_parallel_calls=num_parallel_calls, deterministic=True
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
|
|
419
534
|
def _visible_segments(mask, segments, max_segments):
|
|
420
535
|
"""Keep segments visible in a replayed view and recompute area and bbox."""
|
|
421
536
|
flat = tf.reshape(mask, [-1])
|
|
@@ -464,7 +579,7 @@ def _visible_segments(mask, segments, max_segments):
|
|
|
464
579
|
def replay_panoptic_geometry(
|
|
465
580
|
sample, record, *, class_values, thing_class_values, void_value, max_segments
|
|
466
581
|
):
|
|
467
|
-
"""Replay a version
|
|
582
|
+
"""Replay a record of either version, including integer map and crowd validity."""
|
|
468
583
|
record = _check_record(record)
|
|
469
584
|
tf.debugging.assert_equal(
|
|
470
585
|
tf.size(record["class_values"]),
|
|
@@ -573,6 +688,7 @@ __all__ = [
|
|
|
573
688
|
"sample_panoptic_geometry",
|
|
574
689
|
"validate_dense_sample",
|
|
575
690
|
"replay_dense_geometry",
|
|
691
|
+
"dense_views_from_files",
|
|
576
692
|
"replay_panoptic_geometry",
|
|
577
693
|
"restore_dense_scores",
|
|
578
694
|
"restore_dense_predictions",
|
|
@@ -105,7 +105,7 @@ def _validate_recorded_postprocess(post, flags):
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
def _recorded_geometry_contract(geometry, is_training):
|
|
108
|
-
"""Describe the version-
|
|
108
|
+
"""Describe the version-2 geometry shared by semantic and panoptic views."""
|
|
109
109
|
if not is_training:
|
|
110
110
|
resize_policy = "long_side_cap"
|
|
111
111
|
elif geometry["train_scale_range"] is not None:
|
|
@@ -113,7 +113,7 @@ def _recorded_geometry_contract(geometry, is_training):
|
|
|
113
113
|
else:
|
|
114
114
|
resize_policy = "uniform_integer_short_side"
|
|
115
115
|
return geometry | {
|
|
116
|
-
"record_version":
|
|
116
|
+
"record_version": 2,
|
|
117
117
|
"resize_policy": resize_policy,
|
|
118
118
|
"image_interpolation": "bilinear",
|
|
119
119
|
"mask_interpolation": "nearest",
|
|
@@ -5,7 +5,7 @@ import tensorflow as tf
|
|
|
5
5
|
|
|
6
6
|
from justdata.vision.augmentations.color import color_jitter, photometric_distortion
|
|
7
7
|
from justdata.vision.augmentations.registry import get_crop_strategy
|
|
8
|
-
from justdata.vision.geometry import _train_input_size
|
|
8
|
+
from justdata.vision.geometry import _canonical_seed, _train_input_size
|
|
9
9
|
from justdata.vision.transforms import nhwc_to_nchw, normalize, resize_image
|
|
10
10
|
|
|
11
11
|
|
|
@@ -270,7 +270,7 @@ def recorded_view_augmentations(
|
|
|
270
270
|
|
|
271
271
|
def augmentations(sample, seed):
|
|
272
272
|
geometry_seed, color_seed = tf.unstack(
|
|
273
|
-
tf.random.experimental.stateless_split(seed, 2)
|
|
273
|
+
tf.random.experimental.stateless_split(_canonical_seed(seed), 2)
|
|
274
274
|
)
|
|
275
275
|
if photometric_kwargs is not None:
|
|
276
276
|
sample = sample | {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|