variopinta 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. variopinta-0.1.0/LICENSE +201 -0
  2. variopinta-0.1.0/PKG-INFO +199 -0
  3. variopinta-0.1.0/README.md +170 -0
  4. variopinta-0.1.0/THIRD_PARTY_NOTICES +99 -0
  5. variopinta-0.1.0/pyproject.toml +49 -0
  6. variopinta-0.1.0/python/variopinta/__init__.py +65 -0
  7. variopinta-0.1.0/python/variopinta/_validation.py +303 -0
  8. variopinta-0.1.0/python/variopinta/io.py +121 -0
  9. variopinta-0.1.0/python/variopinta/pipeline.py +86 -0
  10. variopinta-0.1.0/python/variopinta/py.typed +1 -0
  11. variopinta-0.1.0/python/variopinta/transforms.py +614 -0
  12. variopinta-0.1.0/rust/Cargo.lock +599 -0
  13. variopinta-0.1.0/rust/Cargo.toml +21 -0
  14. variopinta-0.1.0/rust/core/Cargo.toml +14 -0
  15. variopinta-0.1.0/rust/core/src/capability.rs +275 -0
  16. variopinta-0.1.0/rust/core/src/catalog.rs +178 -0
  17. variopinta-0.1.0/rust/core/src/compiler.rs +15 -0
  18. variopinta-0.1.0/rust/core/src/engine.rs +676 -0
  19. variopinta-0.1.0/rust/core/src/error.rs +19 -0
  20. variopinta-0.1.0/rust/core/src/explanation.rs +248 -0
  21. variopinta-0.1.0/rust/core/src/kernels/affine.rs +282 -0
  22. variopinta-0.1.0/rust/core/src/kernels/blur.rs +224 -0
  23. variopinta-0.1.0/rust/core/src/kernels/color.rs +184 -0
  24. variopinta-0.1.0/rust/core/src/kernels/layout.rs +321 -0
  25. variopinta-0.1.0/rust/core/src/kernels/mod.rs +80 -0
  26. variopinta-0.1.0/rust/core/src/kernels/point.rs +468 -0
  27. variopinta-0.1.0/rust/core/src/lib.rs +23 -0
  28. variopinta-0.1.0/rust/core/src/model.rs +278 -0
  29. variopinta-0.1.0/rust/core/src/operations.rs +1681 -0
  30. variopinta-0.1.0/rust/core/src/optimization.rs +665 -0
  31. variopinta-0.1.0/rust/core/src/plan/explanation.rs +406 -0
  32. variopinta-0.1.0/rust/core/src/plan/sampling.rs +299 -0
  33. variopinta-0.1.0/rust/core/src/plan/validation.rs +383 -0
  34. variopinta-0.1.0/rust/core/src/plan.rs +1346 -0
  35. variopinta-0.1.0/rust/core/src/workspace.rs +124 -0
  36. variopinta-0.1.0/rust/io/Cargo.toml +14 -0
  37. variopinta-0.1.0/rust/io/src/error.rs +37 -0
  38. variopinta-0.1.0/rust/io/src/jpeg.rs +155 -0
  39. variopinta-0.1.0/rust/io/src/lib.rs +145 -0
  40. variopinta-0.1.0/rust/io/src/model.rs +286 -0
  41. variopinta-0.1.0/rust/io/src/png_codec.rs +145 -0
  42. variopinta-0.1.0/rust/pyext/Cargo.toml +24 -0
  43. variopinta-0.1.0/rust/pyext/src/lib.rs +743 -0
@@ -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 reasonable and customary use in describing the
141
+ origin of the Work and 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 Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
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 [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: variopinta
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 2 - Pre-Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Rust
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: numpy>=2.2.6
18
+ License-File: LICENSE
19
+ License-File: THIRD_PARTY_NOTICES
20
+ Summary: CPU image-augmentation pipelines compiled from Python and executed by optimized Rust kernels
21
+ Keywords: augmentation,computer-vision,image-processing,machine-learning,rust
22
+ License-Expression: Apache-2.0
23
+ Requires-Python: >=3.10, <3.14
24
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
25
+ Project-URL: Homepage, https://github.com/claverru/variopinta
26
+ Project-URL: Repository, https://github.com/claverru/variopinta
27
+ Project-URL: Issues, https://github.com/claverru/variopinta/issues
28
+
29
+ # Variopinta
30
+
31
+ Variopinta is an experimental CPU image-augmentation compiler with a Python
32
+ configuration API and a Rust execution core. It compiles complete pipelines to
33
+ reduce Python/native crossings, reuse buffers, select optimized kernels, and
34
+ report the resulting execution plan.
35
+
36
+ > *Variopinta* is the feminine form of the Spanish *variopinto*: “varied in
37
+ > color or appearance,” from Italian *variopinto*, “varied” and “painted.”
38
+ > — [RAE](https://dle.rae.es/variopinto)
39
+
40
+ Variopinta is image-only and pre-release. The public Python API may change
41
+ between `0.y.0` releases; patch releases preserve documented signatures and
42
+ data contracts unless a correctness or security fix requires otherwise.
43
+
44
+ ## Installation
45
+
46
+ Version 0.1 supports CPython 3.10–3.13 on 64-bit x86 Linux with glibc 2.34 or
47
+ newer. AVX2 is detected at runtime and is not required. Other Python
48
+ implementations, operating systems, architectures, and 32-bit environments are
49
+ not supported.
50
+
51
+ Install Variopinta from PyPI:
52
+
53
+ ```bash
54
+ python -m pip install variopinta
55
+ ```
56
+
57
+ To build from a source checkout, install Rust 1.87 or newer, a C/C++ toolchain,
58
+ CMake, and NASM. On Ubuntu, the native prerequisites are:
59
+
60
+ ```bash
61
+ sudo apt-get update
62
+ sudo apt-get install build-essential cmake nasm
63
+ python -m pip install .
64
+ ```
65
+
66
+ The build uses Maturin through Python build isolation. NumPy is installed as
67
+ the only required runtime dependency.
68
+
69
+ `ToTorch` is optional and requires a PyTorch build compatible with the selected
70
+ Python and Linux environment:
71
+
72
+ ```bash
73
+ python -m pip install torch
74
+ ```
75
+
76
+ ## Quick start
77
+
78
+ ```python
79
+ import numpy as np
80
+ import variopinta as vp
81
+
82
+ pipeline = vp.Compose(
83
+ [
84
+ vp.RandomCrop(256, 256),
85
+ vp.Resize(224, 224),
86
+ vp.HorizontalFlip(p=0.5),
87
+ vp.Normalize(),
88
+ ],
89
+ seed=42,
90
+ ).compile()
91
+
92
+ image = np.zeros((320, 320, 3), dtype=np.uint8)
93
+ output = pipeline(image, key=0)
94
+
95
+ print(output.shape, output.dtype) # (224, 224, 3) float32
96
+ print(pipeline.explain())
97
+ ```
98
+
99
+ `Compose` provides the semantic reference path; `.compile()` selects the
100
+ optimized execution plan. `explain()` reports operations, pixel passes,
101
+ buffers, copies, dtype and layout changes, fusion, and portable fallbacks. Its
102
+ schema version is `2`: each step has an `always`, `conditional`, or `never`
103
+ status, and exact `p=0` routes report only work that can execute.
104
+
105
+ Use an explicit unsigned 64-bit `key` when a result must be independent of call
106
+ order or worker assignment. Omitting it advances the sequence associated with
107
+ the pipeline seed.
108
+
109
+ ## Data contract
110
+
111
+ | Stage | Type | Shape and layout |
112
+ |---|---|---|
113
+ | Pipeline input | NumPy `uint8` | HWC RGB with positive dimensions |
114
+ | Default output | NumPy `uint8` | owned, contiguous HWC RGB |
115
+ | After `Normalize` | NumPy `float32` | owned, contiguous HWC RGB |
116
+ | After terminal `ToTorch` | CPU tensor | contiguous CHW; preserves the current dtype |
117
+
118
+ Non-contiguous NumPy input is made contiguous at the Python boundary.
119
+ `Normalize` must be terminal or immediately precede `ToTorch`; `ToTorch` must
120
+ always be last. Public floating-point configuration is stored at its effective
121
+ finite `float32` value. Values that overflow `float32` or leave a documented
122
+ open or closed domain after conversion raise `ValueError`.
123
+
124
+ ## Transforms
125
+
126
+ - Geometry: `Resize`, `RandomCrop`, `RandomResizedCrop`, `CenterCrop`,
127
+ `PadIfNeeded`, `Affine`, `RandomRotation`, `Perspective`, and
128
+ `GridDistortion`.
129
+ - Flips: `HorizontalFlip` and `VerticalFlip`.
130
+ - Color and filtering: `ColorJitter`, `GaussianBlur`, `GaussianNoise`,
131
+ `Sharpen`, `Grayscale`, `Invert`, `Solarize`, and `Posterize`.
132
+ - Dropout: `CoarseDropout`.
133
+ - Terminal conversion: `Normalize` and `ToTorch`.
134
+
135
+ Transforms are immutable configuration objects and accept an application
136
+ probability `p` where applicable. Geometric operations support the documented
137
+ nearest or bilinear interpolation policies and constant or reflect-101 borders.
138
+ Variopinta defines its own rounding, sampling, and border semantics; it does
139
+ not promise pixel or random-stream identity with another library. `Affine` and
140
+ `RandomRotation` reject an input axis above 16,777,216 before rasterization.
141
+
142
+ ## Image I/O
143
+
144
+ `read_image` and `decode_image` accept JPEG or static PNG and return owned,
145
+ contiguous NumPy arrays. Decode modes are `unchanged`, `gray`, `rgb`, and
146
+ `rgba`.
147
+
148
+ `encode_image` and `write_image` support:
149
+
150
+ - JPEG: `uint8` grayscale or RGB, quality 1–100;
151
+ - PNG: one to four `uint8` or `uint16` channels, compression 0–9.
152
+
153
+ ```python
154
+ import variopinta as vp
155
+
156
+ image = vp.read_image("input.jpg")
157
+ encoded = vp.encode_image(image, format="jpeg", quality=90)
158
+ decoded = vp.decode_image(encoded)
159
+ vp.write_image("output.png", decoded, compression=6)
160
+ ```
161
+
162
+ Format detection uses file contents when decoding. EXIF orientation, metadata
163
+ preservation, and animated PNG are not supported.
164
+
165
+ ## Reproducibility and limits
166
+
167
+ Repeated keyed calls are deterministic for the same installed release,
168
+ execution environment, pipeline, input, seed, and key. Exact pixels or random
169
+ streams are not guaranteed across releases, builds, or platforms. Pin the full
170
+ package build and record those inputs when bit-exact replay matters.
171
+
172
+ Current scope excludes structured targets such as masks and bounding boxes,
173
+ GPU execution, native batches, and Python callbacks inside a pipeline. The
174
+ augmentation path retains the GIL while it borrows NumPy input; native codec
175
+ and file I/O work releases it.
176
+
177
+ ## Performance evidence
178
+
179
+ The controlled benchmark compares Variopinta with Torchvision v2,
180
+ Albumentations, and AlbumentationsX on one reference machine. It measures
181
+ equivalent materialized work and records correctness, copies, buffers, kernel
182
+ paths, hardware, and statistical limits. The results support the compiled
183
+ pipeline design; they do not establish a universal Rust speed advantage.
184
+
185
+ The reproducible harness and committed evidence are available under
186
+ [`benchmarks/`](benchmarks/) and [`results/`](results/).
187
+
188
+ ## Project information
189
+
190
+ - [Changelog](CHANGELOG.md)
191
+ - [Contributing](CONTRIBUTING.md)
192
+ - [Security policy](SECURITY.md)
193
+
194
+ ## License
195
+
196
+ Variopinta is licensed under the [Apache License 2.0](LICENSE). Native wheels
197
+ contain permissively licensed third-party components; their required
198
+ attributions are in [THIRD_PARTY_NOTICES](THIRD_PARTY_NOTICES).
199
+
@@ -0,0 +1,170 @@
1
+ # Variopinta
2
+
3
+ Variopinta is an experimental CPU image-augmentation compiler with a Python
4
+ configuration API and a Rust execution core. It compiles complete pipelines to
5
+ reduce Python/native crossings, reuse buffers, select optimized kernels, and
6
+ report the resulting execution plan.
7
+
8
+ > *Variopinta* is the feminine form of the Spanish *variopinto*: “varied in
9
+ > color or appearance,” from Italian *variopinto*, “varied” and “painted.”
10
+ > — [RAE](https://dle.rae.es/variopinto)
11
+
12
+ Variopinta is image-only and pre-release. The public Python API may change
13
+ between `0.y.0` releases; patch releases preserve documented signatures and
14
+ data contracts unless a correctness or security fix requires otherwise.
15
+
16
+ ## Installation
17
+
18
+ Version 0.1 supports CPython 3.10–3.13 on 64-bit x86 Linux with glibc 2.34 or
19
+ newer. AVX2 is detected at runtime and is not required. Other Python
20
+ implementations, operating systems, architectures, and 32-bit environments are
21
+ not supported.
22
+
23
+ Install Variopinta from PyPI:
24
+
25
+ ```bash
26
+ python -m pip install variopinta
27
+ ```
28
+
29
+ To build from a source checkout, install Rust 1.87 or newer, a C/C++ toolchain,
30
+ CMake, and NASM. On Ubuntu, the native prerequisites are:
31
+
32
+ ```bash
33
+ sudo apt-get update
34
+ sudo apt-get install build-essential cmake nasm
35
+ python -m pip install .
36
+ ```
37
+
38
+ The build uses Maturin through Python build isolation. NumPy is installed as
39
+ the only required runtime dependency.
40
+
41
+ `ToTorch` is optional and requires a PyTorch build compatible with the selected
42
+ Python and Linux environment:
43
+
44
+ ```bash
45
+ python -m pip install torch
46
+ ```
47
+
48
+ ## Quick start
49
+
50
+ ```python
51
+ import numpy as np
52
+ import variopinta as vp
53
+
54
+ pipeline = vp.Compose(
55
+ [
56
+ vp.RandomCrop(256, 256),
57
+ vp.Resize(224, 224),
58
+ vp.HorizontalFlip(p=0.5),
59
+ vp.Normalize(),
60
+ ],
61
+ seed=42,
62
+ ).compile()
63
+
64
+ image = np.zeros((320, 320, 3), dtype=np.uint8)
65
+ output = pipeline(image, key=0)
66
+
67
+ print(output.shape, output.dtype) # (224, 224, 3) float32
68
+ print(pipeline.explain())
69
+ ```
70
+
71
+ `Compose` provides the semantic reference path; `.compile()` selects the
72
+ optimized execution plan. `explain()` reports operations, pixel passes,
73
+ buffers, copies, dtype and layout changes, fusion, and portable fallbacks. Its
74
+ schema version is `2`: each step has an `always`, `conditional`, or `never`
75
+ status, and exact `p=0` routes report only work that can execute.
76
+
77
+ Use an explicit unsigned 64-bit `key` when a result must be independent of call
78
+ order or worker assignment. Omitting it advances the sequence associated with
79
+ the pipeline seed.
80
+
81
+ ## Data contract
82
+
83
+ | Stage | Type | Shape and layout |
84
+ |---|---|---|
85
+ | Pipeline input | NumPy `uint8` | HWC RGB with positive dimensions |
86
+ | Default output | NumPy `uint8` | owned, contiguous HWC RGB |
87
+ | After `Normalize` | NumPy `float32` | owned, contiguous HWC RGB |
88
+ | After terminal `ToTorch` | CPU tensor | contiguous CHW; preserves the current dtype |
89
+
90
+ Non-contiguous NumPy input is made contiguous at the Python boundary.
91
+ `Normalize` must be terminal or immediately precede `ToTorch`; `ToTorch` must
92
+ always be last. Public floating-point configuration is stored at its effective
93
+ finite `float32` value. Values that overflow `float32` or leave a documented
94
+ open or closed domain after conversion raise `ValueError`.
95
+
96
+ ## Transforms
97
+
98
+ - Geometry: `Resize`, `RandomCrop`, `RandomResizedCrop`, `CenterCrop`,
99
+ `PadIfNeeded`, `Affine`, `RandomRotation`, `Perspective`, and
100
+ `GridDistortion`.
101
+ - Flips: `HorizontalFlip` and `VerticalFlip`.
102
+ - Color and filtering: `ColorJitter`, `GaussianBlur`, `GaussianNoise`,
103
+ `Sharpen`, `Grayscale`, `Invert`, `Solarize`, and `Posterize`.
104
+ - Dropout: `CoarseDropout`.
105
+ - Terminal conversion: `Normalize` and `ToTorch`.
106
+
107
+ Transforms are immutable configuration objects and accept an application
108
+ probability `p` where applicable. Geometric operations support the documented
109
+ nearest or bilinear interpolation policies and constant or reflect-101 borders.
110
+ Variopinta defines its own rounding, sampling, and border semantics; it does
111
+ not promise pixel or random-stream identity with another library. `Affine` and
112
+ `RandomRotation` reject an input axis above 16,777,216 before rasterization.
113
+
114
+ ## Image I/O
115
+
116
+ `read_image` and `decode_image` accept JPEG or static PNG and return owned,
117
+ contiguous NumPy arrays. Decode modes are `unchanged`, `gray`, `rgb`, and
118
+ `rgba`.
119
+
120
+ `encode_image` and `write_image` support:
121
+
122
+ - JPEG: `uint8` grayscale or RGB, quality 1–100;
123
+ - PNG: one to four `uint8` or `uint16` channels, compression 0–9.
124
+
125
+ ```python
126
+ import variopinta as vp
127
+
128
+ image = vp.read_image("input.jpg")
129
+ encoded = vp.encode_image(image, format="jpeg", quality=90)
130
+ decoded = vp.decode_image(encoded)
131
+ vp.write_image("output.png", decoded, compression=6)
132
+ ```
133
+
134
+ Format detection uses file contents when decoding. EXIF orientation, metadata
135
+ preservation, and animated PNG are not supported.
136
+
137
+ ## Reproducibility and limits
138
+
139
+ Repeated keyed calls are deterministic for the same installed release,
140
+ execution environment, pipeline, input, seed, and key. Exact pixels or random
141
+ streams are not guaranteed across releases, builds, or platforms. Pin the full
142
+ package build and record those inputs when bit-exact replay matters.
143
+
144
+ Current scope excludes structured targets such as masks and bounding boxes,
145
+ GPU execution, native batches, and Python callbacks inside a pipeline. The
146
+ augmentation path retains the GIL while it borrows NumPy input; native codec
147
+ and file I/O work releases it.
148
+
149
+ ## Performance evidence
150
+
151
+ The controlled benchmark compares Variopinta with Torchvision v2,
152
+ Albumentations, and AlbumentationsX on one reference machine. It measures
153
+ equivalent materialized work and records correctness, copies, buffers, kernel
154
+ paths, hardware, and statistical limits. The results support the compiled
155
+ pipeline design; they do not establish a universal Rust speed advantage.
156
+
157
+ The reproducible harness and committed evidence are available under
158
+ [`benchmarks/`](benchmarks/) and [`results/`](results/).
159
+
160
+ ## Project information
161
+
162
+ - [Changelog](CHANGELOG.md)
163
+ - [Contributing](CONTRIBUTING.md)
164
+ - [Security policy](SECURITY.md)
165
+
166
+ ## License
167
+
168
+ Variopinta is licensed under the [Apache License 2.0](LICENSE). Native wheels
169
+ contain permissively licensed third-party components; their required
170
+ attributions are in [THIRD_PARTY_NOTICES](THIRD_PARTY_NOTICES).
@@ -0,0 +1,99 @@
1
+ Variopinta third-party notices
2
+ ==============================
3
+
4
+ Variopinta wheels contain compiled third-party components. Dependency versions
5
+ are recorded in rust/Cargo.lock. Rust components that offer Apache-2.0 as a
6
+ licensing option are redistributed under that option; the Apache-2.0 text is in
7
+ LICENSE. The components below require additional notices.
8
+
9
+ rust-numpy
10
+ ----------
11
+
12
+ The Rust `numpy` crate is distributed under the BSD 2-Clause License.
13
+
14
+ Copyright (c) 2017, Toshiki Teramura
15
+ All rights reserved.
16
+
17
+ Redistribution and use in source and binary forms, with or without
18
+ modification, are permitted provided that the following conditions are met:
19
+
20
+ * Redistributions of source code must retain the above copyright notice, this
21
+ list of conditions and the following disclaimer.
22
+
23
+ * Redistributions in binary form must reproduce the above copyright notice,
24
+ this list of conditions and the following disclaimer in the documentation
25
+ and/or other materials provided with the distribution.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+
38
+ MIT-licensed Rust components
39
+ ----------------------------
40
+
41
+ The `memoffset`, `simd-adler32`, `turbojpeg`, and `turbojpeg-sys` crates are
42
+ redistributed under the MIT License.
43
+
44
+ Copyright (c) 2017 Gilad Naaman
45
+ Copyright (c) 2021 Marvin Countryman
46
+ Copyright (c) 2023 Jan Špaček
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining a copy
49
+ of this software and associated documentation files (the "Software"), to deal
50
+ in the Software without restriction, including without limitation the rights
51
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52
+ copies of the Software, and to permit persons to whom the Software is
53
+ furnished to do so, subject to the following conditions:
54
+
55
+ The above copyright notice and this permission notice shall be included in all
56
+ copies or substantial portions of the Software.
57
+
58
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64
+ SOFTWARE.
65
+
66
+ libjpeg-turbo 3.1.0
67
+ -------------------
68
+
69
+ The vendored `libjpeg-turbo` library is covered by the IJG License and the
70
+ Modified (3-clause) BSD License. In accordance with the IJG License:
71
+
72
+ This software is based in part on the work of the Independent JPEG Group.
73
+
74
+ Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.
75
+ Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
76
+
77
+ Redistribution and use in source and binary forms, with or without
78
+ modification, are permitted provided that the following conditions are met:
79
+
80
+ * Redistributions of source code must retain the above copyright notice,
81
+ this list of conditions and the following disclaimer.
82
+ * Redistributions in binary form must reproduce the above copyright notice,
83
+ this list of conditions and the following disclaimer in the documentation
84
+ and/or other materials provided with the distribution.
85
+ * Neither the name of the libjpeg-turbo Project nor the names of its
86
+ contributors may be used to endorse or promote products derived from this
87
+ software without specific prior written permission.
88
+
89
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
90
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
92
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
93
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
94
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
95
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
96
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
97
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
98
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
99
+ POSSIBILITY OF SUCH DAMAGE.