attr-eomt 3.1.0__tar.gz → 3.1.1__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 (86) hide show
  1. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.github/workflows/prerelease.yml +3 -2
  2. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.github/workflows/publish.yml +8 -6
  3. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.github/workflows/release.yml +3 -1
  4. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.github/workflows/tests.yml +3 -0
  5. attr_eomt-3.1.1/CHANGELOG.md +228 -0
  6. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/PKG-INFO +21 -12
  7. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/README.md +13 -5
  8. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/__init__.py +2 -1
  9. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/api.py +120 -37
  10. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/aux_cls.py +8 -3
  11. attr_eomt-3.1.1/eomt/configs/coco.yaml +10 -0
  12. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/coco.py +92 -34
  13. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/config.py +4 -3
  14. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/subjects.py +24 -23
  15. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/transforms.py +146 -26
  16. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/__init__.py +2 -2
  17. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/match.py +7 -5
  18. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/predict.py +178 -32
  19. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/train.py +165 -27
  20. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/validate.py +67 -21
  21. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/loss.py +33 -18
  22. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/model.py +5 -3
  23. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/postprocess.py +4 -6
  24. attr_eomt-3.1.1/eomt/preprocess.py +303 -0
  25. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/serialization.py +6 -3
  26. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/tta.py +22 -8
  27. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/examples/track.py +1 -1
  28. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/pyproject.toml +6 -8
  29. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/run.yaml +2 -1
  30. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/match.py +1 -1
  31. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/train.py +17 -2
  32. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/site/index.html +2 -2
  33. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_architecture.py +90 -0
  34. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_augment.py +27 -0
  35. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_multiview.py +8 -5
  36. attr_eomt-3.1.1/tests/test_predict_pipeline.py +225 -0
  37. attr_eomt-3.1.1/tests/test_review_fixes.py +127 -0
  38. attr_eomt-3.1.1/tests/test_rle_gpu.py +55 -0
  39. attr_eomt-3.1.1/tests/test_train_speed.py +45 -0
  40. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/uv.lock +12 -19
  41. attr_eomt-3.1.0/CHANGELOG.md +0 -100
  42. attr_eomt-3.1.0/configs/coco.yaml +0 -10
  43. attr_eomt-3.1.0/eomt/preprocess.py +0 -144
  44. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.github/workflows/pages.yml +0 -0
  45. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/.gitignore +0 -0
  46. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/LICENSE +0 -0
  47. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/docs/assets/00-hero-banner.png +0 -0
  48. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/docs/assets/00-hero-banner.svg +0 -0
  49. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/docs/examples/sample.jpg +0 -0
  50. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/_log.py +0 -0
  51. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/box_loss.py +0 -0
  52. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/config.py +0 -0
  53. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/__init__.py +0 -0
  54. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/data/download.py +0 -0
  55. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/device.py +0 -0
  56. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/ema.py +0 -0
  57. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/engine/distributed.py +0 -0
  58. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/lora.py +0 -0
  59. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/matcher.py +0 -0
  60. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/plotting.py +0 -0
  61. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/progress.py +0 -0
  62. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/reid.py +0 -0
  63. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/eomt/visualize.py +0 -0
  64. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/README.md +0 -0
  65. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/annotations/instances_train.json +0 -0
  66. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/annotations/instances_val.json +0 -0
  67. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/data.yaml +0 -0
  68. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/images/train/.gitkeep +0 -0
  69. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/sample_data/images/val/.gitkeep +0 -0
  70. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/export.py +0 -0
  71. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/info.py +0 -0
  72. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/predict.py +0 -0
  73. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/push_to_hub.py +0 -0
  74. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/scripts/val.py +0 -0
  75. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_api.py +0 -0
  76. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_ddp.py +0 -0
  77. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_parity.py +0 -0
  78. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_recipe.py +0 -0
  79. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_regression_attr.py +0 -0
  80. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_reid.py +0 -0
  81. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_run_config.py +0 -0
  82. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_smoke.py +0 -0
  83. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_sweep.py +0 -0
  84. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tests/test_tta.py +0 -0
  85. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tools/attr_tagger/README.md +0 -0
  86. {attr_eomt-3.1.0 → attr_eomt-3.1.1}/tools/attr_tagger/tag.py +0 -0
@@ -16,7 +16,8 @@ name: prerelease
16
16
  # (merge to main with the final version).
17
17
  #
18
18
  # NOTE: the PyPI trusted publisher (workflow publish.yml, environment pypi) must accept runs from branches other
19
- # than main: if the `pypi` environment limits its deployment branches, allow these branches (or tags) there.
19
+ # than main: if the `pypi` environment limits its deployment branches, allow the pre-release tags (v*rc*, ...) there,
20
+ # not every branch, and keep Required reviewers on the environment so each publish is approved.
20
21
 
21
22
  on:
22
23
  push:
@@ -40,7 +41,7 @@ jobs:
40
41
  run: |
41
42
  VERSION=$(grep -m1 -E '^version *= *"' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')
42
43
  echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43
- if ! python3 -c "import re, sys; sys.exit(0 if re.search(r'(a|b|rc|\.dev)[0-9]+$', '$VERSION') else 1)"; then
44
+ if ! [[ "$VERSION" =~ (a|b|rc|\.dev)[0-9]+$ ]]; then # matched in bash: the version is never pasted into code
44
45
  echo "::error::$VERSION is not a pre-release version (X.Y.ZaN / bN / rcN / .devN); final releases go through release.yml"
45
46
  exit 1
46
47
  fi
@@ -1,19 +1,21 @@
1
1
  name: publish
2
2
 
3
- # Builds the package and publishes to PyPI when a GitHub Release is published.
3
+ # Builds the package and publishes it to PyPI. Only release.yml and prerelease.yml call it, after the tests pass and the
4
+ # GitHub Release is cut: it has no trigger of its own, so nothing reaches PyPI untested. To publish again, re-run the
5
+ # failed `publish` job of that release run.
4
6
  # Uses PyPI Trusted Publishing (OIDC) — no API token stored as a secret.
5
7
  # One-time setup on PyPI: project Settings -> Publishing -> add a trusted publisher
6
8
  # owner: imagra93 repo: attr-eomt workflow: publish.yml environment: pypi
9
+ # Recommended on GitHub: Settings -> Environments -> pypi -> Required reviewers, so a publish waits for an approval.
7
10
 
8
11
  on:
9
- release:
10
- types: [published]
11
- workflow_dispatch: # allow manual runs (e.g. re-publishing an existing release)
12
- workflow_call: # called by release.yml after it cuts a Release on a version bump
12
+ workflow_call: # release.yml / prerelease.yml, after their tests and Release
13
13
 
14
14
  jobs:
15
15
  build:
16
16
  runs-on: ubuntu-latest
17
+ permissions:
18
+ contents: read
17
19
  steps:
18
20
  - uses: actions/checkout@v5
19
21
  - name: Install uv
@@ -21,7 +23,7 @@ jobs:
21
23
  - name: Build sdist + wheel
22
24
  run: uv build
23
25
  - name: Check metadata
24
- run: uvx twine check dist/*
26
+ run: uvx twine==7.0.0 check dist/* # 7.0: Metadata-Version 2.5 (hatchling >= 1.32); the PyPI action uses 7.0.0 too
25
27
  - uses: actions/upload-artifact@v4
26
28
  with:
27
29
  name: dist
@@ -67,7 +67,9 @@ jobs:
67
67
  VERSION: ${{ needs.check.outputs.version }}
68
68
  run: |
69
69
  # a pre-release version (aN / bN / rcN / .devN) merged to main is released as a GitHub pre-release
70
- PRE=$(python3 -c "import re; print('--prerelease' if re.search(r'(a|b|rc|\.dev)[0-9]+$', '$VERSION') else '')")
70
+ # (matched in bash: the version is never pasted into code)
71
+ PRE=""
72
+ if [[ "$VERSION" =~ (a|b|rc|\.dev)[0-9]+$ ]]; then PRE=--prerelease; fi
71
73
  gh release create "v$VERSION" \
72
74
  --title "v$VERSION" \
73
75
  --generate-notes \
@@ -6,6 +6,9 @@ on:
6
6
  pull_request:
7
7
  workflow_call: # callable by release.yml to gate a release on tests passing
8
8
 
9
+ permissions:
10
+ contents: read
11
+
9
12
  jobs:
10
13
  test:
11
14
  runs-on: ubuntu-latest
@@ -0,0 +1,228 @@
1
+ # Changelog
2
+
3
+ ## 3.1.1 (2026-12-01)
4
+
5
+ Faster training, validation, data loading and inference, new training options, and fixes from a review of the
6
+ whole package; no change to the models or checkpoints.
7
+
8
+ - **Dependencies**:
9
+ - `torch>=2.6` / `torchvision>=0.21`. On older torch, a crafted `.pt` can run code despite `weights_only=True`
10
+ (CVE-2025-32434); `load_raw` refuses to load checkpoints there.
11
+ - `torchao` dropped, since nothing imports it.
12
+ - OpenCV and supervision move to the `track` extra (`pip install "attr-eomt[track]"`, for `examples/track.py`); the
13
+ `dev` extra keeps OpenCV for the augmentation tests.
14
+ - The build backend is bounded (`hatchling>=1.27,<2`).
15
+ - **Packaging**: `data="coco"` works from an installed wheel. `coco.yaml` ships inside the package, and COCO 2017
16
+ downloads into `$EOMT_DATASETS/coco`, else `./datasets/coco` under the current directory. In a source checkout it
17
+ went to `configs/datasets/coco`.
18
+ - **Release CI**:
19
+ - `publish.yml` runs only when `release.yml` / `prerelease.yml` call it, after their tests, so nothing reaches PyPI
20
+ untested.
21
+ - Workflows get read-only `permissions`.
22
+ - The version is matched in bash instead of being pasted into Python code.
23
+ - `twine` is pinned.
24
+ - **Validation speed**: the masks are run-length encoded where they are, on the GPU (`encode_masks`), byte for byte as
25
+ pycocotools. `_records` takes 0.05 s instead of 1.7 s for 100 detections of a 12 MP photo; a validation is 5x faster
26
+ on 1024 px photos and 13x on 3 MP ones, with identical metrics.
27
+ - **Data loading speed**: samples are bit-identical, for less time and memory.
28
+ - Masks stay one byte per pixel until they are resized, shrunk in exact integers, decoded into one buffer, and
29
+ flipped after the shrink; an empty mask is found from its RLE.
30
+ - A 12 MP photo with 20 instances takes 0.29 s instead of 1.4 s per sample, and 0.46 GB instead of 2.3 GB.
31
+ - **Training without host-device waits**: the Hungarian assignments reach the GPU in one non-blocking copy, the
32
+ instance count stays a Python number, and the attribute heads' checks are read at once. Multi-view groups and
33
+ partners are built without blocking copies. That is ~133 waits for the GPU per step down to ~10, with equivalent
34
+ results (the same matching, the loss to ~1 ulp, gradients within the GPU's own run-to-run noise): +1-2 % on a ViT-L
35
+ step, more on smaller models.
36
+ - **Frozen ViT blocks**:
37
+ - `optim.freeze_blocks: k` freezes the patch embedding and ViT blocks `0..k-1` (only blocks below the queries; not
38
+ with `multiview`). With `llrd` 0.8 those blocks learn at 0.6-7 % of the head's LR anyway. **On a ViT-L it defaults
39
+ to 8**; S / B train every block (not measured), a multi-view post-training and a resumed run are unchanged
40
+ (a resume keeps its run's setting, 0 for runs from before).
41
+ - Measured with ViT-L 644 on two datasets: steps 9-18 % faster and 2.8 GiB less, with the same or a better mAP:
42
+ +0.009 (95 % CI [+0.006, +0.012]) and +0.0035 class-agnostic (CI [+0.0004, +0.0067]), where two seeds of one
43
+ recipe differ by up to 0.003. On a full training set too: +0.0014 class-agnostic (CI [-0.002, +0.004]), 18 %
44
+ faster, 2.8 GiB less.
45
+ - 12 blocks: steps 16-25 % faster and 4.1 GiB less, but -0.007 mAP on one of the two datasets.
46
+ - **Weights of chosen epochs**: `train(save_epochs=...)` (`train.save_epochs` in the run config) also keeps the EMA
47
+ weights of those epochs, stored as `best.pt` is (the weights only, with the LoRA factors merged, and the epoch's
48
+ metrics row), in `weights/epoch<N>.pt`. It takes a list of epochs, numbered from 0 as `metrics.csv` and the log
49
+ number them, or `k` for every k-th epoch (`k - 1`, `2k - 1`, ...). Use it to compare the epochs of a run on a test
50
+ the validation does not stand for. An epoch whose masked attention is still annealing is saved too, with a note in
51
+ the log: predict runs it mask-free, unlike its training.
52
+ - **Checking a run without training it**: `eomt.check_train(data, model=..., **kw)` and `scripts/train.py --check` check
53
+ a run as `EoMT(model).train(data, **kw)` would start it: the run config (its sections, their keys and values, the
54
+ `train` keys it cannot set), the `train()` keywords, and the files the run reads (the data, the checkpoint it starts
55
+ from, the fixed validation sets). It takes ~2 s, with no GPU, and loads and downloads nothing. It prints the run's
56
+ settings, or the first problem and exit status 1. `train()` checks its settings the same way before it loads anything.
57
+ - **Validation every epoch by default** (`val.interval`: 2 -> 1): the metrics of every epoch, and `best.pt` chosen
58
+ among all of them. This costs one validation per epoch; in the ViT-L runs measured, ~2 % of an epoch with a photo
59
+ validation and ~8 % with a multi-view set validation. `val: {interval: 2}` restores the old behaviour.
60
+ - **Inference speed**: `predict()` returns identical results, bit for bit (every tensor of 72 real photos, at the
61
+ checkpoint's thresholds and at conf 0), faster. ViT-L 644 on an RTX 5090: one 12 MP photo takes ~72 ms instead of
62
+ ~158 ms, a folder of 12 MP photos ~44 ms/photo instead of ~165; one ~1 MP photo ~24 ms instead of ~35, a folder of
63
+ them ~17.5 ms/photo instead of ~20.
64
+ - JPEG / PNG files are decoded by torchvision (`eomt.preprocess.decode_image` / `read_image`, the same pixels as
65
+ PIL's, with the EXIF orientation applied as `open_image` does). A CUDA model gets them resized on its GPU,
66
+ with `preprocess_torch`, whose input is `preprocess_numpy`'s bit for bit; it now also takes a `(3, H, W)` uint8
67
+ tensor. Other formats, and layouts the two decoders might not agree on, are decoded by PIL as before. Pillow 13
68
+ runs its vertical pass first when the height shrinks by more than twice as many pixels as the width; the GPU
69
+ resize follows the installed Pillow's order, so the input stays PIL's bit for bit with Pillow 12 and 13.
70
+ - A folder is decoded with one job per photo (8 threads, two batches ahead) instead of one per batch.
71
+ - Masks come to the CPU through two reused pinned buffers, in chunks, the transfer of one overlapping the copy of
72
+ the one before: 10 masks of 12 MP take ~6 ms instead of ~50 ms. Every result keeps its own memory.
73
+ - On a folder or a list, each batch's results come to the CPU in a thread and on a CUDA stream of their own while
74
+ the next batch runs: with 12 MP photos and ~7.6 detections each, 26.8 -> 23.6 ms/photo at batch 8 and 28.0 ->
75
+ 23.8 at batch 1 (unchanged with ~1 detection per photo).
76
+ - Photos in memory (a PIL image of any mode, or an RGB uint8 array) given to `predict_image` / `predict_batch` /
77
+ `predict_set` on a CUDA model are resized on the GPU too, from pinned memory: the same input bit for bit, 1.2 ms
78
+ instead of 9.4 ms for a 1 MP photo. An app that runs two models on each 1-3 MP photo went from 103 to 89 ms
79
+ per photo and from 90 to 76 ms per video frame, with identical responses.
80
+ - **Test-time augmentation** (`augment=` / `tiles=`, `predict_views`): on a CUDA model the photo is uploaded once
81
+ and each view cut, mirrored and resized on the GPU (the same input as PIL's, bit for bit), and the views' match
82
+ matrix is read back once instead of once per pair of views. Identical results; a 1024 px photo with ViT-L 644 on
83
+ an RTX 5090: 12 views (flip, scales 1 and 1.5, tiles) 272 -> 259 ms, 2 views (flip) 40 -> 36 ms. The forward
84
+ passes are now ~93 % of the time.
85
+ - **Blur**: on a photo the augmentation shrinks, the blur is applied after the resize, with sigma x the scale.
86
+ - It uses a Gaussian corrected for small sigmas, and is skipped under 0.1 output px.
87
+ - Before a JPEG step, or without a shrink, it stays at source resolution as before, now separable.
88
+ - Blurred samples change by about 0.2 grey levels; every other output is identical.
89
+ - A "degraded" 12 MP anchor takes 1.1 s instead of 4.0 s.
90
+
91
+ - **Prediction**:
92
+ - `EoMT.predict` / `predict()` take a PIL image, an RGB array or a list (of files, folders and images), not only a
93
+ path. Their results are on the CPU: a folder's full-resolution masks no longer pile up on the GPU (16 phone
94
+ photos held 18 GiB).
95
+ - Detections are always returned highest score first; before, that held only when `max_det` cut them.
96
+ - Image files are turned upright by their EXIF orientation (`eomt.preprocess.open_image`), so a portrait phone photo
97
+ is predicted and returned as a viewer shows it.
98
+ - `predict_image(array, augment=True)` works.
99
+ - `preprocess_numpy` resizes a PIL image as it is, and `open_image` decodes a photo with no copy when it needs no
100
+ turn: two to four fewer full-resolution copies per 12 MP photo (139 -> 77 ms end to end for one), identical output.
101
+ - **Data**:
102
+ - A dataset image is turned upright only when its record proves the annotations were made upright (a portrait record
103
+ of landscape pixels, or the reverse); before, such masks were stretched onto the sideways pixels.
104
+ - A missing `iscrowd` is 0, and degenerate polygons are left out at load time, instead of failing in a worker.
105
+ - When every instance is cropped away, the photo has no target, instead of an invented class-0 one (a full-image box
106
+ for the detect family).
107
+ - Instances that mosaic / mixup / copy-paste paste into a negative image pass the keep filter.
108
+ - Attribute sidecar values that are bare numbers map to their labels.
109
+ - `flip_aware` swaps on a mirror image (one flip, horizontal or vertical), not on a horizontal flip.
110
+ - The set validation letterboxes with `round`, as inference does (it gave 643 for 644).
111
+ - `instances_val_retrain.json` is the `val` split.
112
+ - **Training**:
113
+ - The Hungarian costs are computed in fp32 (under autocast their matmuls ran in bf16).
114
+ - A dataset smaller than one batch trains on a partial batch (the sample run trained 0 steps and reported success);
115
+ an empty loader raises.
116
+ - A resume without `name` continues in the resumed run's folder (it wrote into `runs/train/eomt-<size>`).
117
+ - Unknown `aux.per_head` heads raise.
118
+ - TF32 / cuDNN settings are restored when `train()` returns.
119
+ - `EoMT.train()` releases its loaded copy of the model during the run.
120
+ - **Validation**:
121
+ - The val JSON's classes must be the model's, in the same order. Another order scored every class as another one.
122
+ - COCO's `-1` (no ground truth) is NaN.
123
+ - The best-F1 link threshold is found exactly over the observed similarities (a 0.01 grid gave `match_thres=0.02`).
124
+ - **Checkpoints**:
125
+ - A bf16 checkpoint re-saves as bf16 (`dtype="fp32"` for full precision).
126
+ - Saving over an existing file works on Windows.
127
+ - `push_to_hub` refuses an existing repo of the other visibility and a file name with folders, and leaves out the
128
+ run's local data paths, provenance and per-field metrics.
129
+
130
+ ## 3.1.0 (2026-11-19)
131
+
132
+ The multi-view post-training, rebuilt from what the 3.0 runs showed: the cross-view attention's null token never
133
+ learned (its logit stayed at its starting value), the matching head linked hardly better than plain re-identification
134
+ (link F1 0.68 vs 0.66), and the photos' own features never saw the other photos. **Multi-view checkpoints of 3.0 and
135
+ before are refused** (their single-photo starting checkpoints load as before, with identical predictions).
136
+
137
+ - **Cross-view attention, gated.** Each row's update is gated per head by `tanh` of a learned function of the row,
138
+ starting at 0 (the sublayer starts as the identity), in place of the null token and the LayerScale. The patch tokens,
139
+ pooled 2x2, attend to the other photos too and their update is spread back over the patches, so the mask features see
140
+ the other photos (`xview: {patches, pool}`; ~+3 % per step). One attention call per set. The output projection has no
141
+ bias, so a closed gate adds nothing.
142
+ - **Attention supervision** (`multiview.attn_w`): a loss pointing each linked query's cross-view attention at the same
143
+ instance in the other photos (its mask and its query there).
144
+ - **The set matcher** (`eomt.matcher.SetMatcher`, replaces the matching head, `match_dim`, `match_residual` and the
145
+ sigmoid matching loss): the detected instances of the photos, by their query embedding and mask box, attend to each
146
+ other within and across photos; every two instances of two photos get a probability of being the same (a dual softmax
147
+ with a "no partner in that photo" bin), trained on the `instance_id` links (`multiview.match_w`). Inference links with
148
+ it (the photos predicted together as one set, any other two as a pair) at its calibrated probability threshold.
149
+ - **LoRA** (`multiview.lora: {rank, blocks, alpha}`, `eomt.lora`): the attention of the frozen ViT blocks below the query
150
+ blocks adapts; the trainer's `best.pt` holds the merged weights, and any checkpoint with factors is merged on loading.
151
+ Trainable group `lora`; the `match_head` group is now `matcher`.
152
+ - **Validation**: `sets/{match,reid}_oracle/*`, the links between the annotated instances themselves (linking with
153
+ perfect detection); the blocks below the queries run once per set for the photos alone and together;
154
+ `val.final_epochs` validates every epoch at the end of a run validated every `interval` epochs.
155
+ - **Training**: DDP no longer searches for unused parameters (every trainable parameter joins each step's graph) and
156
+ keeps the gradients in its buckets.
157
+ - `EoMTModel.forward(trunk=..., keep_xview_attn=...)` and `EoMTEncoder.encode_trunk()`.
158
+ - **Groups of a subject's photos** (`eomt.engine.predict`): a photo may be in several groups (predicted in the first,
159
+ context in the others, `group_owners`); `fill=True` (`subject_groups`, `predict_subject`, `predict(subject=True)`,
160
+ `match`, `scripts/match.py --fill`) tops the last default group up with the photos before it, so 5 photos at 4 a
161
+ time are two groups of 4 instead of 4 + 1; `similar_groups(features, max_views)` groups photos by
162
+ `photo_similarity`: the cosine of one or several descriptions of each photo (e.g. a first model's class areas and the
163
+ photo's appearance), averaged with `weights`, optionally `center`ed, filled the same way.
164
+ - **`photo_embed`**: every forward returns each photo's mean final patch token `(B, hidden)` over the photo (the
165
+ letterbox padding left out); `predict_set` results carry it, and `predict_batch(photo_embed=True)`.
166
+ - `predict_batch` / `predict_set` / `predict_subject` take RGB arrays as well as PIL images, already preprocessed inputs
167
+ (`prepared`: numpy or tensors, from `preprocess_numpy` or `preprocess_torch`) and the size each result is returned at
168
+ (`sizes`).
169
+
170
+
171
+ ## 3.0.0 (2026-11-19)
172
+
173
+ A cleanup for a public release: one way to do each thing, one config per concern, and the options no trained model
174
+ uses removed. **Checkpoints of 2.x load and predict exactly as before** (they are upgraded on load); run configs and
175
+ code written for 2.x need the changes below.
176
+
177
+ ### Training: settings by concern
178
+
179
+ `train()` keeps the keywords of the run (data, `size`, `family`, `epochs`, `batch`, `nominal_batch`, `imgsz`, `device`,
180
+ `workers`, `seed`, `project` / `name`, `resume` / `init_weights`, `keep_empty`, `stop_after_epochs`, `logger`) and takes
181
+ the rest by section, each a dataclass or a mapping (and a section of the run config YAML):
182
+
183
+ | 2.x keyword | 3.0 |
184
+ |---|---|
185
+ | `lr0`, `weight_decay`, `llrd`, `backbone_lr_mult`, `poly_power`, `warmup_steps`, `clip_norm`, `ema`, `ema_decay`, `ema_tau` | `optim: {...}` |
186
+ | `mask_anneal`, `mask_anneal_start` / `_end`, `--mask-free` | `optim.mask_anneal` (true: the reference windows; false: mask-free) |
187
+ | `fpn_scales`, `num_upscale_blocks`, loss weights, `iou_aware_cls`, `quality_weight`, `aux_head_*` | `model: {...}` (IoU-aware targets and the quality head now on by default) |
188
+ | `aux_w`, `aux_w_per_head`, `aux_class_weights`, `aux_iou_gate`, `aux_class_gate` | `aux: {w, per_head, class_weights, iou_gate, class_gate}` |
189
+ | `val_interval`, `val_imgsz`, `conf_thres`, `max_det`, `val_group_by`, `best_key` | `val: {interval, imgsz, conf_thres, max_det, group_by, best_key}` |
190
+ | `flip_prob`, `min_scale`, `max_scale`, `train_aug` (YAML) | `aug: {...}` |
191
+ | `accum`, `amp_dtype`, `tf32`, `prefetch`, `letterbox`, `ddp` | removed (from `nominal_batch`; bf16 where supported; always on) |
192
+
193
+ Removed options: `box_head`, `deep_supervision=False`, `hires_*`, `aux_balance`, `aux_w_warmup`, the gradient probe.
194
+
195
+ ### Several photos of one subject
196
+
197
+ `multiview` is a post-training on **real** sets (images with `subject_id`, annotations with `instance_id`):
198
+ `{xview, matching, match_w, gate, trainable, sets, val_sets}`. `xview` and `matching` are each optional: the matching
199
+ head trains without cross-view attention too. `trainable` takes the presets `new` and `query_blocks`, or a dict.
200
+ New: `sets.groups` (an image field) trains on the fixed groups of photos an application predicts together, each once
201
+ per epoch, with a `sets.p_random` share of random sets; validation scores those groups.
202
+
203
+ Removed: synthetic sets (`sets.cases`, distractors, mirrored copies, `p_subject`, `focus`), the `real` sub-section (the
204
+ run's own data is the sets' data), the refiner, view types, `xview.keys`, `xview_scale`, the InfoNCE and dustbin
205
+ matching losses (sigmoid only), `match_dim` / `match_residual` / `match_tau` (a residual head at the hidden size),
206
+ `match_neg_conf` (the inference threshold), `match_hard_*`, `linked_w`, `consistency_*`, `harm_w`, `val_synthetic`,
207
+ per-part `val_interval`. The metrics are `val/sets/...` (was `val/real/...`); the link sources are `match` and `reid`.
208
+
209
+ ### Inference and API
210
+
211
+ - `EoMT.match()` is the one linking entry point, for any number of photos (`infer_match` is gone);
212
+ `predict_subject(identities=True)` links in code. The grouping modes `partition` / `anchor` are gone (`groups=`).
213
+ - `predict()` batches (`batch=8`), decodes in the background, streams (`stream=True`) and runs in bf16 by default.
214
+ - `val()` defaults to the checkpoint's own validation data.
215
+ - Tracking moved to `examples/track.py`; int8 compression and the auxiliary box head were removed.
216
+ - Checkpoints load with `weights_only=True` and strictly; `eomt.migrate_checkpoint` upgrades 2.x ones.
217
+ - Messages go through the standard `eomt` logger (stdout, INFO) instead of `print`:
218
+ `logging.getLogger("eomt").setLevel(logging.WARNING)` silences them.
219
+
220
+ ### Fixes
221
+
222
+ - Unaugmented validation sets are placed as inference letterboxes the photos (they were placed at random): the stored
223
+ link threshold is calibrated on the inputs inference sees, and fixed sets read back reproduce the trainer's numbers.
224
+ - Validation runs in bf16 like training and inference (it ran in fp16), in PyTorch's default numerics.
225
+ - Thin or tiny instances are no longer dropped from the set validation's ground truth.
226
+ - `last.pt` is written before validating; a resumed run reads the best so far from `best.pt` too.
227
+ - No GPU synchronisation per forward pass (masked-attention probabilities) or per training step; the final matching is
228
+ solved once per step; `predict()` keeps no full-resolution float copies of the masks.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: attr-eomt
3
- Version: 3.1.0
3
+ Version: 3.1.1
4
4
  Summary: Standalone EoMT (Encoder-only Mask Transformer) for instance segmentation, with DINOv2 init, COCO training/validation and inference.
5
5
  Project-URL: Homepage, https://github.com/imagra93/attr-eomt
6
6
  Project-URL: Documentation, https://imagra93.github.io/attr-eomt
@@ -17,25 +17,26 @@ Requires-Python: >=3.10
17
17
  Requires-Dist: huggingface-hub>=0.23.0
18
18
  Requires-Dist: matplotlib>=3.5.0
19
19
  Requires-Dist: numpy>=1.19.0
20
- Requires-Dist: opencv-python>=4.8.0
21
20
  Requires-Dist: pillow>=9.1.0
22
21
  Requires-Dist: pycocotools>=2.0.0
23
22
  Requires-Dist: pyyaml>=6.0
24
23
  Requires-Dist: requests>=2.25.0
25
24
  Requires-Dist: scipy>=1.7.0
26
- Requires-Dist: supervision<0.30,>=0.22.0
27
- Requires-Dist: torch>=2.4.0
28
- Requires-Dist: torchao>=0.7.0
29
- Requires-Dist: torchvision>=0.19.0
25
+ Requires-Dist: torch>=2.6.0
26
+ Requires-Dist: torchvision>=0.21.0
30
27
  Requires-Dist: tqdm>=4.65.0
31
28
  Requires-Dist: transformers>=5.1.0
32
29
  Provides-Extra: dev
33
30
  Requires-Dist: build>=1.0; extra == 'dev'
31
+ Requires-Dist: opencv-python>=4.8.0; extra == 'dev'
34
32
  Requires-Dist: pytest>=7.0; extra == 'dev'
35
- Requires-Dist: twine>=5.0; extra == 'dev'
33
+ Requires-Dist: twine>=7.0; extra == 'dev'
36
34
  Provides-Extra: logging
37
35
  Requires-Dist: tensorboard>=2.10; extra == 'logging'
38
36
  Requires-Dist: wandb>=0.15; extra == 'logging'
37
+ Provides-Extra: track
38
+ Requires-Dist: opencv-python>=4.8.0; extra == 'track'
39
+ Requires-Dist: supervision<0.30,>=0.22.0; extra == 'track'
39
40
  Description-Content-Type: text/markdown
40
41
 
41
42
  <div align="center">
@@ -92,9 +93,10 @@ identities = model.match("photos/subject_42/") # one identity per physical i
92
93
  ```bash
93
94
  pip install attr-eomt # from PyPI
94
95
  pip install -e ".[dev]" # from source (editable; [dev] adds pytest)
96
+ pip install "attr-eomt[track]" # + OpenCV and supervision, for examples/track.py
95
97
  ```
96
98
 
97
- Python 3.10+, PyTorch 2.4+. Training and inference run in bf16 on GPUs that support it.
99
+ Python 3.10+, PyTorch 2.6+. Training and inference run in bf16 on GPUs that support it.
98
100
 
99
101
  ---
100
102
 
@@ -226,24 +228,26 @@ inference: {conf_thres: 0.3} # saved with the model: the defaults of
226
228
 
227
229
  | section | what it holds (`eomt.engine.train`) |
228
230
  |---------|--------------------------------------|
229
- | `train` | the keywords of `train()`: `epochs`, `batch` (per GPU), `nominal_batch` (16: the rest is accumulated), `imgsz`, `workers`, `seed`, `init_weights`, `project` / `name`, `stop_after_epochs` |
231
+ | `train` | the keywords of `train()`: `epochs`, `batch` (per GPU), `nominal_batch` (16: the rest is accumulated), `imgsz`, `workers`, `seed`, `init_weights`, `project` / `name`, `stop_after_epochs`, `save_epochs` (also keep these epochs' weights, `weights/epoch<N>.pt`) |
230
232
  | `model` | the architecture and loss weights of a new model (`ModelConfig`): `fpn_scales`, `num_upscale_blocks`, `iou_aware_cls`, `quality_weight`, the attribute heads' shape |
231
- | `optim` | `OptimConfig`: `lr0`, `llrd`, `warmup_steps`, `poly_power`, `clip_norm`, `ema_decay`, `mask_anneal` |
233
+ | `optim` | `OptimConfig`: `lr0`, `llrd`, `warmup_steps`, `poly_power`, `clip_norm`, `ema_decay`, `mask_anneal`, `freeze_blocks` |
232
234
  | `aux` | how the attribute heads train (`AuxConfig`): `w`, `per_head`, `class_weights`, `iou_gate`, `class_gate` |
233
235
  | `aug` | the augmentation (`AugConfig`) |
234
- | `val` | `ValConfig`: `interval`, `imgsz`, `group_by` (metrics per value of an image field), `best_key` |
236
+ | `val` | `ValConfig`: `interval` (1: every epoch), `imgsz`, `group_by` (metrics per value of an image field), `best_key` |
235
237
  | `multiview` | a post-training on photos of one subject (`MultiviewConfig`, below) |
236
238
  | `attributes`, `inference` | the heads and how each learns; the predict defaults saved in the checkpoint |
237
239
 
238
240
  Arguments beat the file: a keyword of `EoMT.train()` replaces a `train` value, and a section given as a mapping is merged
239
241
  over the YAML's key by key (`model.train(data="run.yaml", optim={"lr0": 5e-5})`). An unknown key stops the run before it
240
- starts. The resolved run is written to `args.yaml` in the run folder and into every checkpoint.
242
+ starts, and `check_train(data, model=...)` (`--check`) checks a run in seconds without training it: the config, the
243
+ keywords and the files it reads. The resolved run is written to `args.yaml` in the run folder and into every checkpoint.
241
244
 
242
245
  ```bash
243
246
  python scripts/train.py --data run.yaml --size l --device 0,1 # the run as its YAML says, two GPUs
244
247
  python scripts/train.py --data run.yaml --epochs 1 --set optim.lr0=5e-5 # any setting: --set SECTION.KEY=VALUE
245
248
  python scripts/train.py --data run.yaml --weights best.pt --set optim.mask_anneal=false # warm start
246
249
  python scripts/train.py --data run.yaml --resume runs/train/my-run # continue a run exactly
250
+ python scripts/train.py --data run.yaml --weights best.pt --check # check the run, no training
247
251
  ```
248
252
 
249
253
  ---
@@ -380,6 +384,11 @@ resolved run, with the warm-start weights and the data files and their SHA-256.
380
384
  A **short fine-tune** wants its own recipe: a lower `optim.lr0`, a shorter `optim.warmup_steps`, a lower
381
385
  `optim.ema_decay`, and `optim.mask_anneal: false` for a model deployed mask-free.
382
386
 
387
+ **Frozen blocks**: on a ViT-L, the patch embedding and the first 8 ViT blocks stay frozen by default
388
+ (`optim.freeze_blocks`, `0` trains them all): +9-18 % steps/s and 2.8 GiB less, with the same or a slightly better mAP
389
+ in our runs. 12 blocks lost 0.007 mAP on one dataset. S / B models train every block (not measured there). A resumed run
390
+ keeps what it started with.
391
+
383
392
  **Several GPUs**: `device="0,1"` trains with one process per GPU; `batch` is per GPU and `nominal_batch` stays the global
384
393
  batch, so the optimizer steps are those of one GPU. Write the training call under `if __name__ == "__main__":` (the
385
394
  processes are spawned).
@@ -52,9 +52,10 @@ identities = model.match("photos/subject_42/") # one identity per physical i
52
52
  ```bash
53
53
  pip install attr-eomt # from PyPI
54
54
  pip install -e ".[dev]" # from source (editable; [dev] adds pytest)
55
+ pip install "attr-eomt[track]" # + OpenCV and supervision, for examples/track.py
55
56
  ```
56
57
 
57
- Python 3.10+, PyTorch 2.4+. Training and inference run in bf16 on GPUs that support it.
58
+ Python 3.10+, PyTorch 2.6+. Training and inference run in bf16 on GPUs that support it.
58
59
 
59
60
  ---
60
61
 
@@ -186,24 +187,26 @@ inference: {conf_thres: 0.3} # saved with the model: the defaults of
186
187
 
187
188
  | section | what it holds (`eomt.engine.train`) |
188
189
  |---------|--------------------------------------|
189
- | `train` | the keywords of `train()`: `epochs`, `batch` (per GPU), `nominal_batch` (16: the rest is accumulated), `imgsz`, `workers`, `seed`, `init_weights`, `project` / `name`, `stop_after_epochs` |
190
+ | `train` | the keywords of `train()`: `epochs`, `batch` (per GPU), `nominal_batch` (16: the rest is accumulated), `imgsz`, `workers`, `seed`, `init_weights`, `project` / `name`, `stop_after_epochs`, `save_epochs` (also keep these epochs' weights, `weights/epoch<N>.pt`) |
190
191
  | `model` | the architecture and loss weights of a new model (`ModelConfig`): `fpn_scales`, `num_upscale_blocks`, `iou_aware_cls`, `quality_weight`, the attribute heads' shape |
191
- | `optim` | `OptimConfig`: `lr0`, `llrd`, `warmup_steps`, `poly_power`, `clip_norm`, `ema_decay`, `mask_anneal` |
192
+ | `optim` | `OptimConfig`: `lr0`, `llrd`, `warmup_steps`, `poly_power`, `clip_norm`, `ema_decay`, `mask_anneal`, `freeze_blocks` |
192
193
  | `aux` | how the attribute heads train (`AuxConfig`): `w`, `per_head`, `class_weights`, `iou_gate`, `class_gate` |
193
194
  | `aug` | the augmentation (`AugConfig`) |
194
- | `val` | `ValConfig`: `interval`, `imgsz`, `group_by` (metrics per value of an image field), `best_key` |
195
+ | `val` | `ValConfig`: `interval` (1: every epoch), `imgsz`, `group_by` (metrics per value of an image field), `best_key` |
195
196
  | `multiview` | a post-training on photos of one subject (`MultiviewConfig`, below) |
196
197
  | `attributes`, `inference` | the heads and how each learns; the predict defaults saved in the checkpoint |
197
198
 
198
199
  Arguments beat the file: a keyword of `EoMT.train()` replaces a `train` value, and a section given as a mapping is merged
199
200
  over the YAML's key by key (`model.train(data="run.yaml", optim={"lr0": 5e-5})`). An unknown key stops the run before it
200
- starts. The resolved run is written to `args.yaml` in the run folder and into every checkpoint.
201
+ starts, and `check_train(data, model=...)` (`--check`) checks a run in seconds without training it: the config, the
202
+ keywords and the files it reads. The resolved run is written to `args.yaml` in the run folder and into every checkpoint.
201
203
 
202
204
  ```bash
203
205
  python scripts/train.py --data run.yaml --size l --device 0,1 # the run as its YAML says, two GPUs
204
206
  python scripts/train.py --data run.yaml --epochs 1 --set optim.lr0=5e-5 # any setting: --set SECTION.KEY=VALUE
205
207
  python scripts/train.py --data run.yaml --weights best.pt --set optim.mask_anneal=false # warm start
206
208
  python scripts/train.py --data run.yaml --resume runs/train/my-run # continue a run exactly
209
+ python scripts/train.py --data run.yaml --weights best.pt --check # check the run, no training
207
210
  ```
208
211
 
209
212
  ---
@@ -340,6 +343,11 @@ resolved run, with the warm-start weights and the data files and their SHA-256.
340
343
  A **short fine-tune** wants its own recipe: a lower `optim.lr0`, a shorter `optim.warmup_steps`, a lower
341
344
  `optim.ema_decay`, and `optim.mask_anneal: false` for a model deployed mask-free.
342
345
 
346
+ **Frozen blocks**: on a ViT-L, the patch embedding and the first 8 ViT blocks stay frozen by default
347
+ (`optim.freeze_blocks`, `0` trains them all): +9-18 % steps/s and 2.8 GiB less, with the same or a slightly better mAP
348
+ in our runs. 12 blocks lost 0.007 mAP on one dataset. S / B models train every block (not measured there). A resumed run
349
+ keeps what it started with.
350
+
343
351
  **Several GPUs**: `device="0,1"` trains with one process per GPU; `batch` is per GPU and `nominal_batch` stays the global
344
352
  batch, so the optimizer steps are those of one GPU. Write the training call under `if __name__ == "__main__":` (the
345
353
  processes are spawned).
@@ -13,7 +13,7 @@ mappings: ``EoMT("l").train(data=..., optim=OptimConfig(lr0=5e-5))``.
13
13
 
14
14
  from __future__ import annotations
15
15
 
16
- from .api import EoMT
16
+ from .api import EoMT, check_train
17
17
  from .config import EOMT_CONFIGS, SIZES, AuxHeadSpec
18
18
  from .data.subjects import SubjectSetConfig
19
19
  from .data.transforms import AugConfig
@@ -23,6 +23,7 @@ from .serialization import get_version, load_model, migrate_checkpoint, save_che
23
23
 
24
24
  __all__ = [
25
25
  "EoMT",
26
+ "check_train",
26
27
  "AugConfig",
27
28
  "ModelConfig",
28
29
  "OptimConfig",