paraug 0.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.
- paraug-0.1.1/.github/workflows/publish.yml +46 -0
- paraug-0.1.1/.github/workflows/test.yml +55 -0
- paraug-0.1.1/.gitignore +37 -0
- paraug-0.1.1/CHANGELOG.md +51 -0
- paraug-0.1.1/LICENSE +201 -0
- paraug-0.1.1/NOTICE +4 -0
- paraug-0.1.1/PKG-INFO +201 -0
- paraug-0.1.1/README.md +166 -0
- paraug-0.1.1/README_zh-TW.md +161 -0
- paraug-0.1.1/docs/banner.png +0 -0
- paraug-0.1.1/docs/logo.png +0 -0
- paraug-0.1.1/examples/01_quickstart.py +44 -0
- paraug-0.1.1/examples/02_mask_aware.py +42 -0
- paraug-0.1.1/examples/03_cpu_gpu_parity.py +69 -0
- paraug-0.1.1/pyproject.toml +62 -0
- paraug-0.1.1/scripts/audit_spec_keys.py +152 -0
- paraug-0.1.1/src/paraug/__init__.py +31 -0
- paraug-0.1.1/src/paraug/geometric.py +380 -0
- paraug-0.1.1/src/paraug/photometric.py +1112 -0
- paraug-0.1.1/src/paraug/pipeline.py +81 -0
- paraug-0.1.1/src/paraug/utils.py +102 -0
- paraug-0.1.1/tests/conftest.py +10 -0
- paraug-0.1.1/tests/test_geometric.py +68 -0
- paraug-0.1.1/tests/test_parity.py +127 -0
- paraug-0.1.1/tests/test_photometric.py +118 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Triggered when a git tag matching `v*` is pushed. Builds a wheel + sdist
|
|
4
|
+
# from pyproject.toml and uploads to PyPI via OIDC trusted publisher (no API
|
|
5
|
+
# token stored as a secret).
|
|
6
|
+
#
|
|
7
|
+
# Prerequisites on PyPI side:
|
|
8
|
+
# 1. PyPI account exists for the project owner.
|
|
9
|
+
# 2. PyPI "Trusted Publisher" configured for this repo:
|
|
10
|
+
# - Owner: alieuidsh
|
|
11
|
+
# - Repository: paraug
|
|
12
|
+
# - Workflow: publish.yml
|
|
13
|
+
# - Environment: pypi
|
|
14
|
+
# (Set via https://pypi.org/manage/account/publishing/ — for the first
|
|
15
|
+
# release the project entry doesn't exist yet, so use the "pending"
|
|
16
|
+
# publisher form to pre-authorise the first upload.)
|
|
17
|
+
|
|
18
|
+
on:
|
|
19
|
+
push:
|
|
20
|
+
tags:
|
|
21
|
+
- "v*"
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
build-and-publish:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment:
|
|
27
|
+
name: pypi
|
|
28
|
+
url: https://pypi.org/project/paraug/
|
|
29
|
+
permissions:
|
|
30
|
+
id-token: write # OIDC token for PyPI trusted-publisher auth
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.11"
|
|
36
|
+
- name: Install build tooling
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
pip install build
|
|
40
|
+
- name: Build sdist + wheel
|
|
41
|
+
run: python -m build
|
|
42
|
+
- name: Inspect dist/
|
|
43
|
+
run: ls -lh dist/
|
|
44
|
+
- name: Publish to PyPI
|
|
45
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
46
|
+
# No `password:` — OIDC via trusted publisher.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
# NOTE on CUDA parity coverage:
|
|
4
|
+
# GitHub's free runners are CPU-only, so the 13 `test_parity_*_cpu_vs_cuda`
|
|
5
|
+
# tests in `tests/test_parity.py` skip on CI. The 1e-6 elementwise and 2e-4
|
|
6
|
+
# grid_sample tolerances advertised in README are verified locally on
|
|
7
|
+
# developer GPUs (NVIDIA 5060 Ti / 4080 confirmed at v0.1.0 — see
|
|
8
|
+
# CHANGELOG). To enable CI-side CUDA verification, add a self-hosted GPU
|
|
9
|
+
# runner and remove the `runs-on: ubuntu-latest` constraint on a new job.
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
branches: [main]
|
|
14
|
+
pull_request:
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
- uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: ${{ matrix.python-version }}
|
|
28
|
+
- name: Install
|
|
29
|
+
run: |
|
|
30
|
+
python -m pip install --upgrade pip
|
|
31
|
+
pip install -e ".[dev]"
|
|
32
|
+
- name: Audit spec-key consistency
|
|
33
|
+
run: python scripts/audit_spec_keys.py
|
|
34
|
+
- name: Note — CUDA parity tests skip on free runners
|
|
35
|
+
run: |
|
|
36
|
+
echo "::warning::CUDA-only tests in tests/test_parity.py (13 cases) will SKIP on this CPU-only runner."
|
|
37
|
+
echo "::warning::The 1e-6 / 2e-4 CPU↔CUDA tolerance claim is verified locally; see README parity-comparison section."
|
|
38
|
+
- name: Run tests (CPU only — parity tests skip CUDA on free runners)
|
|
39
|
+
run: pytest tests/ -v --tb=short -ra
|
|
40
|
+
|
|
41
|
+
example-smoke:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: actions/setup-python@v5
|
|
46
|
+
with:
|
|
47
|
+
python-version: "3.11"
|
|
48
|
+
- name: Install
|
|
49
|
+
run: pip install -e .
|
|
50
|
+
- name: Run examples
|
|
51
|
+
run: |
|
|
52
|
+
python examples/01_quickstart.py
|
|
53
|
+
python examples/02_mask_aware.py
|
|
54
|
+
echo "::warning::example 03_cpu_gpu_parity will SKIP its CUDA assertions on this CPU-only runner."
|
|
55
|
+
python examples/03_cpu_gpu_parity.py
|
paraug-0.1.1/.gitignore
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.egg-info/
|
|
6
|
+
.eggs/
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
|
|
14
|
+
# Virtual env
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
.python-version
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
.DS_Store
|
|
26
|
+
|
|
27
|
+
# Coverage
|
|
28
|
+
.coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
coverage.xml
|
|
31
|
+
|
|
32
|
+
# Build artifacts
|
|
33
|
+
*.so
|
|
34
|
+
|
|
35
|
+
# Local outputs
|
|
36
|
+
outputs/
|
|
37
|
+
scratch/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to paraug are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.1] - 2026-05-15
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- README hero banner (`docs/banner.png`) and project logo (`docs/logo.png`).
|
|
12
|
+
- Traditional Chinese translation: `README_zh-TW.md` with a language switcher
|
|
13
|
+
in the main README.
|
|
14
|
+
- `.github/workflows/publish.yml` — OIDC trusted-publisher workflow that
|
|
15
|
+
builds an sdist + wheel and uploads to PyPI when a `v*` git tag is pushed.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Installation instructions now point to `pip install git+https://...` as the
|
|
20
|
+
primary path until the PyPI release is live, instead of the previous
|
|
21
|
+
unconditional `pip install paraug` (which would have failed).
|
|
22
|
+
|
|
23
|
+
## [0.1.0] - 2026-05-15
|
|
24
|
+
|
|
25
|
+
Initial public release.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- `AugPipeline(config)` — single entry point accepting a dict of geometric
|
|
30
|
+
and photometric primitive specs. Returns `(image_aug, mask_aug)` with
|
|
31
|
+
deterministic per-item RNG.
|
|
32
|
+
- **7 geometric primitives**: `affine`, `perspective`, `random_crop_pad`,
|
|
33
|
+
`elastic_transform`, `optical_distortion`, `random_shadow`, `tps`.
|
|
34
|
+
- **24 photometric primitives**: gamma, gaussian_noise, gaussian_blur,
|
|
35
|
+
motion_blur, salt_pepper_noise, color_jitter, hue_shift, random_grayscale,
|
|
36
|
+
lighting, jpeg_approx, sharpness, clahe, local_contrast, vignette,
|
|
37
|
+
specular_highlight, specular_streaks, cutout, salt_patches,
|
|
38
|
+
paper_texture_overlay, watermark, random_text_overlay, background_compose,
|
|
39
|
+
stains, creases.
|
|
40
|
+
- **CPU/GPU bit-exact parity**: per-primitive RNG is sampled on CPU
|
|
41
|
+
regardless of tensor device, so the same seed produces identical output
|
|
42
|
+
across CPU and CUDA back-ends within 1e-6 elementwise / 2e-4
|
|
43
|
+
grid_sample-class tolerance.
|
|
44
|
+
- `set_deterministic(state=True, warn_only=True)` global toggle wrapping
|
|
45
|
+
`torch.use_deterministic_algorithms` and cuDNN flags.
|
|
46
|
+
- `per_item_seed(seed_base, epoch, step, item_i, primitive)` and
|
|
47
|
+
`cpu_generator(seed)` exposed for callers that need to mirror the RNG
|
|
48
|
+
outside the pipeline.
|
|
49
|
+
- `scripts/audit_spec_keys.py` — AST-based check that every test fixture and
|
|
50
|
+
example dict uses spec keys that match the primitive's
|
|
51
|
+
`spec.get("KEY", default)` reads. Runs in CI; exits non-zero on mismatch.
|
paraug-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 alieuidsh
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
paraug-0.1.1/NOTICE
ADDED
paraug-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: paraug
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Parity Augmentation — bit-exact CPU/GPU parity for image augmentation
|
|
5
|
+
Project-URL: Homepage, https://github.com/alieuidsh/paraug
|
|
6
|
+
Project-URL: Repository, https://github.com/alieuidsh/paraug
|
|
7
|
+
Project-URL: Issues, https://github.com/alieuidsh/paraug/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/alieuidsh/paraug/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: alieuidsh <alieuidsh@users.noreply.github.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: augmentation,computer-vision,cpu-gpu-parity,deep-learning,deterministic,image,pytorch
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: numpy>=1.24
|
|
28
|
+
Requires-Dist: torch>=2.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
32
|
+
Provides-Extra: opencv
|
|
33
|
+
Requires-Dist: opencv-python>=4.5; extra == 'opencv'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# paraug
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
> **Bit-exact CPU/GPU parity for image augmentation.**
|
|
41
|
+
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
[]()
|
|
44
|
+
|
|
45
|
+
**Languages**: English | [繁體中文](README_zh-TW.md)
|
|
46
|
+
|
|
47
|
+
`paraug` is a PyTorch-native augmentation library that guarantees **the same
|
|
48
|
+
seed produces the same output on CPU and CUDA**. Per-primitive RNG is sampled
|
|
49
|
+
on CPU regardless of tensor device, so a training run that randomly switches
|
|
50
|
+
between CPU and GPU stages — or a unit test that swaps backends — stays
|
|
51
|
+
deterministic.
|
|
52
|
+
|
|
53
|
+
## Why parity matters
|
|
54
|
+
|
|
55
|
+
Most augmentation libraries (albumentations, kornia, torchvision) use device-
|
|
56
|
+
local RNG. Same seed, different output across CPU/CUDA. This bites in three
|
|
57
|
+
places:
|
|
58
|
+
|
|
59
|
+
1. **Reproducibility**: paper-to-code lineage breaks when a reviewer can't
|
|
60
|
+
match published numbers.
|
|
61
|
+
2. **Debugging**: CPU-side unit tests don't catch GPU-only bugs and vice
|
|
62
|
+
versa.
|
|
63
|
+
3. **Distributed training**: workers on heterogeneous hardware drift apart.
|
|
64
|
+
|
|
65
|
+
paraug fixes this by isolating RNG to CPU (`torch.Generator(device="cpu")`)
|
|
66
|
+
and routing only the deterministic torch ops through device. Tolerance:
|
|
67
|
+
|
|
68
|
+
- **Elementwise ops** (gamma, noise, color jitter, …): atol 1e-6
|
|
69
|
+
- **`grid_sample`-class ops** (affine, perspective, tps, …): atol 2e-4
|
|
70
|
+
(bilinear ulp drift across ATen vs cuDNN)
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install git+https://github.com/alieuidsh/paraug.git
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> PyPI release (`pip install paraug`) coming once the v0.1.x publish workflow
|
|
79
|
+
> is wired up — see issue tracker for status.
|
|
80
|
+
|
|
81
|
+
## Quickstart
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import torch
|
|
85
|
+
from paraug import AugPipeline
|
|
86
|
+
|
|
87
|
+
aug = AugPipeline({
|
|
88
|
+
"geometric": {
|
|
89
|
+
"affine": {"p": 1.0, "rot_deg": 15.0, "scale_range": (0.9, 1.1)},
|
|
90
|
+
"tps": {"p": 0.5, "max_disp": 12.0, "n_ctrl": 5},
|
|
91
|
+
},
|
|
92
|
+
"photometric": {
|
|
93
|
+
"gamma": {"p": 0.5},
|
|
94
|
+
"color_jitter": {"p": 0.5},
|
|
95
|
+
"gaussian_blur": {"p": 0.3},
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
img = torch.rand(2, 3, 256, 256) # (B, C, H, W)
|
|
100
|
+
mask = torch.ones(2, 1, 256, 256) # optional
|
|
101
|
+
|
|
102
|
+
img_out, mask_out = aug(img, mask=mask, seed_base=42, epoch=0, step=0)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The same call on GPU is bit-exact within tolerance:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
img_gpu = img.cuda()
|
|
109
|
+
mask_gpu = mask.cuda()
|
|
110
|
+
img_cuda, mask_cuda = aug(img_gpu, mask=mask_gpu, seed_base=42, epoch=0, step=0)
|
|
111
|
+
assert (img_out - img_cuda.cpu()).abs().max() < 2e-4
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Primitives
|
|
115
|
+
|
|
116
|
+
### Geometric (7)
|
|
117
|
+
|
|
118
|
+
| Name | Description |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `affine` | Rotation + scale + translation via `F.affine_grid` |
|
|
121
|
+
| `perspective` | 4-point homography from corner jitter |
|
|
122
|
+
| `random_crop_pad` | Scale-then-pad crop, area-preserving |
|
|
123
|
+
| `elastic_transform` | Bilinear-upsampled random displacement field |
|
|
124
|
+
| `optical_distortion` | Radial barrel / pincushion (k·r²) |
|
|
125
|
+
| `random_shadow` | Soft-blurred triangle multiplicative shadow |
|
|
126
|
+
| `tps` | Thin-plate-spline-like warp from low-res control grid |
|
|
127
|
+
|
|
128
|
+
### Photometric (24)
|
|
129
|
+
|
|
130
|
+
Intensity / color: `gamma`, `color_jitter`, `hue_shift`, `random_grayscale`,
|
|
131
|
+
`lighting`, `clahe`, `local_contrast`, `sharpness`.
|
|
132
|
+
|
|
133
|
+
Noise: `gaussian_noise`, `salt_pepper_noise`, `salt_patches`.
|
|
134
|
+
|
|
135
|
+
Blur / artifacts: `gaussian_blur`, `motion_blur`, `jpeg_approx`.
|
|
136
|
+
|
|
137
|
+
Lighting: `vignette`, `specular_highlight`, `specular_streaks`.
|
|
138
|
+
|
|
139
|
+
Content overlays: `cutout`, `paper_texture_overlay`, `watermark`,
|
|
140
|
+
`random_text_overlay`, `background_compose`, `stains`, `creases`.
|
|
141
|
+
|
|
142
|
+
## Parity comparison
|
|
143
|
+
|
|
144
|
+
| Library | Bit-exact CPU↔GPU | Per-item RNG | GPU native | Mask-aware | Batch-native | # Geometric¹ | # Photometric¹ | License |
|
|
145
|
+
|---|---|---|---|---|---|---|---|---|
|
|
146
|
+
| **paraug** | **✓** (1e-6 / 2e-4)² | ✓ | ✓ (torch) | ✓ | ✓ | 7 | 24 | Apache 2.0 |
|
|
147
|
+
| albumentations | ✗ (numpy-only) | ✓ | ✗ | ✓ | partial | ~20 | ~50+ | MIT |
|
|
148
|
+
| kornia | ✗ (device-local RNG) | ✓ | ✓ (torch) | ✓ | ✓ | ~10 | ~45 | Apache 2.0 |
|
|
149
|
+
| torchvision.v2 | ✗ (device-local RNG) | ✓ | ✓ (torch) | partial | ✓ | ~18 | ~12 | BSD-3 |
|
|
150
|
+
| imgaug | ✗ (numpy-only) | ✓ | ✗ | ✓ | partial | ~20 | ~40 | MIT |
|
|
151
|
+
| augly | ✗ (PIL-only) | ✓ | ✗ | ✗ | ✗ | ~5 | ~20 | MIT |
|
|
152
|
+
|
|
153
|
+
<sub>¹ External counts are approximate as of 2026-05 (sampled from each project's
|
|
154
|
+
`__init__.py` / docs index). Versions move fast — consult each project's
|
|
155
|
+
authoritative API reference for current numbers. paraug counts are
|
|
156
|
+
code-exact (`len(GEOMETRIC_PRIMITIVES)` / `len(PHOTOMETRIC_PRIMITIVES)`).</sub>
|
|
157
|
+
|
|
158
|
+
<sub>² Tolerance verified by `tests/test_parity.py` on NVIDIA 5060 Ti + 4080
|
|
159
|
+
at v0.1.0; exact bounds: 1e-6 for the 6 elementwise photometric ops listed
|
|
160
|
+
in `PHOTO_ELEMENTWISE` (gamma / gaussian_noise / color_jitter / vignette /
|
|
161
|
+
cutout / hue_shift), 2e-4 for grid_sample-class (geometric) and conv-class
|
|
162
|
+
(blur) ops. **GitHub free CI runners are CPU-only**, so the 13 CUDA parity
|
|
163
|
+
tests skip on CI — community verification on additional GPU SKUs is
|
|
164
|
+
welcome (open a PR with the result, or run `pytest tests/test_parity.py -k
|
|
165
|
+
cpu_vs_cuda` locally and post the output).</sub>
|
|
166
|
+
|
|
167
|
+
### When to use paraug
|
|
168
|
+
|
|
169
|
+
- Cross-device reproducibility (paper-grade ablation where CPU↔GPU drift breaks a baseline)
|
|
170
|
+
- Distributed training on heterogeneous hardware
|
|
171
|
+
- Unit-test-friendly augmentation pipelines (CPU-side RNG means a test on a free CI runner reproduces a developer's GPU result)
|
|
172
|
+
|
|
173
|
+
### When **NOT** to use paraug
|
|
174
|
+
|
|
175
|
+
- You need 50+ primitive options out of the box → try `albumentations` or `imgaug`
|
|
176
|
+
- You need PIL-style per-image API → try `augly`
|
|
177
|
+
- You need built-in compositional ops like `OneOf` / `SomeOf` → try `albumentations`
|
|
178
|
+
|
|
179
|
+
## Examples
|
|
180
|
+
|
|
181
|
+
See `examples/`:
|
|
182
|
+
|
|
183
|
+
- `01_quickstart.py` — minimal load → augment → save
|
|
184
|
+
- `02_mask_aware.py` — image + segmentation mask warped together
|
|
185
|
+
- `03_cpu_gpu_parity.py` — same seed on CPU and CUDA, assert
|
|
186
|
+
`max_abs_diff < 2e-4`
|
|
187
|
+
|
|
188
|
+
## Citation
|
|
189
|
+
|
|
190
|
+
```bibtex
|
|
191
|
+
@software{paraug2026,
|
|
192
|
+
author = {alieuidsh},
|
|
193
|
+
title = {paraug: Bit-exact CPU/GPU parity for image augmentation},
|
|
194
|
+
year = {2026},
|
|
195
|
+
url = {https://github.com/alieuidsh/paraug},
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|