batchgenerators 0.25.1__tar.gz → 0.25.2__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.
- batchgenerators-0.25.2/PKG-INFO +400 -0
- batchgenerators-0.25.2/README.md +178 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/nondet_multi_threaded_augmenter.py +18 -16
- batchgenerators-0.25.2/batchgenerators.egg-info/PKG-INFO +400 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators.egg-info/SOURCES.txt +2 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators.egg-info/dependency_links.txt +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators.egg-info/requires.txt +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators.egg-info/top_level.txt +1 -0
- batchgenerators-0.25.2/pyproject.toml +38 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/setup.cfg +1 -1
- batchgenerators-0.25.2/setup.py +3 -0
- batchgenerators-0.25.1/PKG-INFO +0 -19
- batchgenerators-0.25.1/batchgenerators.egg-info/PKG-INFO +0 -19
- batchgenerators-0.25.1/setup.py +0 -25
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/LICENSE +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/color_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/crop_and_pad_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/noise_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/normalizations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/resample_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/spatial_transformations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/augmentations/utils.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/data_loader.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/dataset.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/multi_threaded_augmenter.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/dataloading/single_threaded_augmenter.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/datasets/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/datasets/cifar.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/brats2017/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/brats2017/brats2017_dataloader_2D.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/brats2017/brats2017_dataloader_3D.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/brats2017/brats2017_preprocessing.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/brats2017/config.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/cifar10.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/examples/multithreaded_dataloading.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/abstract_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/channel_selection_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/color_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/crop_and_pad_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/local_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/noise_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/resample_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/sample_normalization_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/spatial_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/transforms/utility_transforms.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/utilities/__init__.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/utilities/custom_types.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/utilities/data_splitting.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/batchgenerators/utilities/file_and_folder_operations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_DataLoader.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_augment_zoom.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_axis_mirroring.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_color_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_crop.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_multithreaded_augmenter.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_normalizations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_random_crop.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_resample_augmentations.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_sanity.py +0 -0
- {batchgenerators-0.25.1 → batchgenerators-0.25.2}/tests/test_spatial_transformations.py +0 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: batchgenerators
|
|
3
|
+
Version: 0.25.2
|
|
4
|
+
Summary: Data augmentation toolkit
|
|
5
|
+
Author-email: "Division of Medical Image Computing, German Cancer Research Center AND Applied Computer Vision Lab, Helmholtz Imaging Platform" <f.isensee@dkfz-heidelberg.de>
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
184
|
+
|
|
185
|
+
To apply the Apache License to your work, attach the following
|
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
187
|
+
replaced with your own identifying information. (Don't include
|
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
189
|
+
comment syntax for the file format. We also recommend that a
|
|
190
|
+
file or class name and description of purpose be included on the
|
|
191
|
+
same "printed page" as the copyright notice for easier
|
|
192
|
+
identification within third-party archives.
|
|
193
|
+
|
|
194
|
+
Copyright [2021] [Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
|
|
195
|
+
AND Applied Computer Vision Lab, Helmholtz Imaging Platform]
|
|
196
|
+
|
|
197
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
198
|
+
you may not use this file except in compliance with the License.
|
|
199
|
+
You may obtain a copy of the License at
|
|
200
|
+
|
|
201
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
202
|
+
|
|
203
|
+
Unless required by applicable law or agreed to in writing, software
|
|
204
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
205
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
206
|
+
See the License for the specific language governing permissions and
|
|
207
|
+
limitations under the License.
|
|
208
|
+
Project-URL: Homepage, https://github.com/MIC-DKFZ/batchgenerators
|
|
209
|
+
Keywords: data augmentation,deep learning,image segmentation,image classification,medical image analysis,medical image segmentation
|
|
210
|
+
Description-Content-Type: text/markdown
|
|
211
|
+
License-File: LICENSE
|
|
212
|
+
Requires-Dist: pillow>=7.1.2
|
|
213
|
+
Requires-Dist: numpy>=1.10.2
|
|
214
|
+
Requires-Dist: scipy
|
|
215
|
+
Requires-Dist: scikit-image
|
|
216
|
+
Requires-Dist: scikit-learn
|
|
217
|
+
Requires-Dist: future
|
|
218
|
+
Requires-Dist: pandas
|
|
219
|
+
Requires-Dist: unittest2
|
|
220
|
+
Requires-Dist: threadpoolctl
|
|
221
|
+
Dynamic: license-file
|
|
222
|
+
|
|
223
|
+
# batchgenerators by MIC@DKFZ
|
|
224
|
+
|
|
225
|
+
Copyright German Cancer Research Center (DKFZ) and contributors.
|
|
226
|
+
Please make sure that your usage of this code is in compliance with its
|
|
227
|
+
[`license`](https://github.com/MIC-DKFZ/batchgenerators/blob/master/LICENSE).
|
|
228
|
+
|
|
229
|
+
batchgenerators is a python package for data augmentation. It is developed jointly between the Division of
|
|
230
|
+
Medical Image Computing at the German Cancer Research Center (DKFZ) and the Applied Computer
|
|
231
|
+
Vision Lab of the Helmholtz Imaging Platform.
|
|
232
|
+
|
|
233
|
+
It is not (yet) perfect, but we feel it is good enough to be shared with the community. If you encounter bug, feel free
|
|
234
|
+
to contact us or open a github issue.
|
|
235
|
+
|
|
236
|
+
If you use it please cite the following work:
|
|
237
|
+
```
|
|
238
|
+
Isensee Fabian, Jäger Paul, Wasserthal Jakob, Zimmerer David, Petersen Jens, Kohl Simon,
|
|
239
|
+
Schock Justus, Klein Andre, Roß Tobias, Wirkert Sebastian, Neher Peter, Dinkelacker Stefan,
|
|
240
|
+
Köhler Gregor, Maier-Hein Klaus (2020). batchgenerators - a python framework for data
|
|
241
|
+
augmentation. doi:10.5281/zenodo.3632567
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
batchgenerators also contains the following application-specific augmentations:
|
|
245
|
+
* **Anatomy-informed Data Augmentation**
|
|
246
|
+
Proposed at [MICCAI 2023](https://arxiv.org/abs/2309.03652) for simulation of soft-tissue deformations. Implementation details can be found [here](https://github.com/MIC-DKFZ/anatomy_informed_DA).
|
|
247
|
+
* **Misalignment Data Augmentation**
|
|
248
|
+
Proposed in [Nature Scientific Reports 2023](https://www.nature.com/articles/s41598-023-46747-z)
|
|
249
|
+
for enhancing model's adaptability to diverse misalignments\
|
|
250
|
+
between multi-modal (multi-channel) images and thereby ensuring robust performance. Implementation details can be found [here](https://github.com/MIC-DKFZ/misalignment_DA).
|
|
251
|
+
|
|
252
|
+
If you use these augmentations please cite them too.
|
|
253
|
+
|
|
254
|
+
[](https://travis-ci.com/github/MIC-DKFZ/batchgenerators)
|
|
255
|
+
|
|
256
|
+
## Supported Augmentations
|
|
257
|
+
We supports a variety of augmentations, all of which are compatible with **2D and 3D input data**! (This is something
|
|
258
|
+
that was missing in most other frameworks).
|
|
259
|
+
|
|
260
|
+
* **Spatial Augmentations**
|
|
261
|
+
* mirroring
|
|
262
|
+
* channel translation (to simulate registration errors)
|
|
263
|
+
* elastic deformations
|
|
264
|
+
* rotations
|
|
265
|
+
* scaling
|
|
266
|
+
* resampling
|
|
267
|
+
* multi-channel misalignments
|
|
268
|
+
* **Color Augmentations**
|
|
269
|
+
* brightness (additive, multiplivative)
|
|
270
|
+
* contrast
|
|
271
|
+
* gamma (like gamma correction in photo editing)
|
|
272
|
+
* **Noise Augmentations**
|
|
273
|
+
* Gaussian Noise
|
|
274
|
+
* Rician Noise
|
|
275
|
+
* ...will be expanded in future commits
|
|
276
|
+
* **Cropping**
|
|
277
|
+
* random crop
|
|
278
|
+
* center crop
|
|
279
|
+
* padding
|
|
280
|
+
* **Anatomy-informed Augmentation**
|
|
281
|
+
|
|
282
|
+
Note: Stack transforms by using batchgenerators.transforms.abstract_transforms.Compose. Finish it up by plugging the
|
|
283
|
+
composed transform into our **multithreader**: batchgenerators.dataloading.multi_threaded_augmenter.MultiThreadedAugmenter
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
## How to use it
|
|
287
|
+
|
|
288
|
+
The working principle is simple: Derive from DataLoaderBase class, reimplement generate_train_batch member function and
|
|
289
|
+
use it to stack your augmentations!
|
|
290
|
+
For simple example see `batchgenerators/examples/example_ipynb.ipynb`
|
|
291
|
+
|
|
292
|
+
A heavily commented example for using SlimDataLoaderBase and MultithreadedAugmentor is available at:
|
|
293
|
+
`batchgenerators/examples/multithreaded_with_batches.ipynb`.
|
|
294
|
+
It gives an idea of the interplay between the SlimDataLoaderBase and the MultiThreadedAugmentor.
|
|
295
|
+
The example uses the MultiThreadedAugmentor for loading and augmentation on mutiple processes, while
|
|
296
|
+
covering the entire dataset only once per epoch (basically sampling without replacement).
|
|
297
|
+
|
|
298
|
+
We also now have an extensive example for BraTS2017/2018 with both 2D and 3D DataLoader and augmentations:
|
|
299
|
+
`batchgenerators/examples/brats2017/`
|
|
300
|
+
|
|
301
|
+
There are also CIFAR10/100 datasets and DataLoader available at `batchgenerators/datasets/cifar.py`
|
|
302
|
+
|
|
303
|
+
## Data Structure
|
|
304
|
+
|
|
305
|
+
The data structure that is used internally (and with which you have to comply when implementing generate_train_batch)
|
|
306
|
+
is kept simple as well: It is just a regular python dictionary! We did this to allow maximum flexibility in the kind of
|
|
307
|
+
data that is passed along through the pipeline. The dictionary must have a 'data' key:value pair. It optionally can
|
|
308
|
+
handle a 'seg' key:vlaue pair to hold a segmentation. If a 'seg' key:value pair is present all spatial transformations
|
|
309
|
+
will also be applied to the segmentation! A part from 'data' and 'seg' you are free to do whatever you want (your image
|
|
310
|
+
classification/regression target for example). All key:value pairs other than 'data' and 'seg' will be passed through the
|
|
311
|
+
pipeline unmodified.
|
|
312
|
+
|
|
313
|
+
'data' value must have shape (b, c, x, y) for 2D or shape (b, c, x, y, z) for 3D!
|
|
314
|
+
'seg' value must have shape (b, c, x, y) for 2D or shape (b, c, x, y, z) for 3D! Color channel may be used here to
|
|
315
|
+
allow for several segmentation maps. If you have only one segmentation, make sure to have shape (b, 1, x, y (, z))
|
|
316
|
+
|
|
317
|
+
## How to install locally
|
|
318
|
+
|
|
319
|
+
Install batchgenerators
|
|
320
|
+
```
|
|
321
|
+
pip install --upgrade batchgenerators
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Import as follows
|
|
325
|
+
```
|
|
326
|
+
from batchgenerators.transforms.color_transforms import ContrastAugmentationTransform
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Windows Support is very experimental!
|
|
330
|
+
Batchgenerators makes heavy use of python multiprocessing and python multiprocessing on windows is different from linux.
|
|
331
|
+
To prevent the workers from freezing in windows, you have to guard your code with `if __name__ == '__main__'` and use multiprocessing's [`freeze_support`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support). The executed script may then look like this:
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
# some imports and functions here
|
|
335
|
+
|
|
336
|
+
def main():
|
|
337
|
+
# do some stuff
|
|
338
|
+
|
|
339
|
+
if __name__ == '__main__':
|
|
340
|
+
from multiprocessing import freeze_support
|
|
341
|
+
freeze_support()
|
|
342
|
+
main()
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
This is not required on Linux.
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
## Release Notes
|
|
349
|
+
(only highlights, not an exhaustive list)
|
|
350
|
+
- 0.23.2:
|
|
351
|
+
- Misalignment data augmentation added
|
|
352
|
+
- 0.23.1:
|
|
353
|
+
- Anatomy-informed data augmentation added
|
|
354
|
+
- 0.23:
|
|
355
|
+
- fixed the import mess. `__init__.py` files are now empty. This is a breaking change for some users!
|
|
356
|
+
Please adapt your imports :-)
|
|
357
|
+
- local_transforms are now a thing, check them out!
|
|
358
|
+
- resize_segmentation now uses 'edge' mode and no longer takes a cval argument. Resizing segmentations with constant
|
|
359
|
+
border values (previous default) can cause problems and should not be done.
|
|
360
|
+
- 0.20.0:
|
|
361
|
+
- fixed an issue with MultiThreadedAugmenter not terminating properly after KeyboardInterrupt; Fixed an error
|
|
362
|
+
with the number and order of samples being returned when pin_memory=True; Improved performance by always hiding
|
|
363
|
+
process-process communication bottleneck through threading
|
|
364
|
+
- 0.19.5:
|
|
365
|
+
- fixed OMP_NUM_THREADS issue by using threadpoolctl package; dropped python 2 support (threadpoolctl is not
|
|
366
|
+
available for python 2)
|
|
367
|
+
- 0.19:
|
|
368
|
+
- There is now a complete example for BraTS2017/8 available for both 2D and 3D. Use this if you would like to get
|
|
369
|
+
some insights on how I (Fabian) do my experiments
|
|
370
|
+
- Windows is now supported! Thanks @justusschock for your support!
|
|
371
|
+
- new, simple parametrization of elastic deformation. Use SpatialTransform_2!
|
|
372
|
+
- CIFAR10/100 DataLoader are now available for your convenience
|
|
373
|
+
- a bug in MultiThreadedAugmenter that could interfere with reproducibility is now fixed
|
|
374
|
+
|
|
375
|
+
- 0.18:
|
|
376
|
+
- all augmentations (there are some exceptions though) are implemented on a per-sample basis. This should make it
|
|
377
|
+
easier to use the augmentations outside of the Transforms of batchgenerators
|
|
378
|
+
- applicable Transforms now have a keyword p_per_sample with which the user can specify a probability with which this
|
|
379
|
+
transform is applied to a sample. Before, this was handled by RndTransform and applied to the whole batch (so
|
|
380
|
+
either all samples were augmented or none). Now this decision is made on a per-sample basis and increases
|
|
381
|
+
variability by a lot.
|
|
382
|
+
- following the previous point, RndTransform is now deprecated
|
|
383
|
+
- AlternativeMultiThreadedAugmenter is now deprecated as well (no need to have this anymore)
|
|
384
|
+
- pytorch users can now transform numpy arrays to pytorch tensors within batchgenerators (NumpyToTensor). For some
|
|
385
|
+
reason, inter-process communication is faster with tensors (~factor 4), so this is recommended!
|
|
386
|
+
- if numpy arrays were converted to pytorch tensors, MultithreadedAugmenter now allows to pin the memory as well
|
|
387
|
+
(pin_memory=True). This will happen in a background thread (inspired by pytorch DataLoader). pinned memory can be
|
|
388
|
+
copied to the GPU much faster. My (Fabian) classification experiment with Resnet50 got a speed boost of 12% from just
|
|
389
|
+
that.
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
-------------------------
|
|
393
|
+
|
|
394
|
+
<img src="DKFZ_Logo.png" width="512px" />
|
|
395
|
+
|
|
396
|
+
<img src="HIP_Logo.png" width="512px" />
|
|
397
|
+
|
|
398
|
+
batchgenerators is developed by the [Division of Medical Image Computing](https://www.dkfz.de/en/mic/index.php) of the
|
|
399
|
+
German Cancer Research Center (DKFZ) and the Applied Computer Vision Lab (ACVL) of the
|
|
400
|
+
[Helmholtz Imaging Platform](https://helmholtz-imaging.de).
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# batchgenerators by MIC@DKFZ
|
|
2
|
+
|
|
3
|
+
Copyright German Cancer Research Center (DKFZ) and contributors.
|
|
4
|
+
Please make sure that your usage of this code is in compliance with its
|
|
5
|
+
[`license`](https://github.com/MIC-DKFZ/batchgenerators/blob/master/LICENSE).
|
|
6
|
+
|
|
7
|
+
batchgenerators is a python package for data augmentation. It is developed jointly between the Division of
|
|
8
|
+
Medical Image Computing at the German Cancer Research Center (DKFZ) and the Applied Computer
|
|
9
|
+
Vision Lab of the Helmholtz Imaging Platform.
|
|
10
|
+
|
|
11
|
+
It is not (yet) perfect, but we feel it is good enough to be shared with the community. If you encounter bug, feel free
|
|
12
|
+
to contact us or open a github issue.
|
|
13
|
+
|
|
14
|
+
If you use it please cite the following work:
|
|
15
|
+
```
|
|
16
|
+
Isensee Fabian, Jäger Paul, Wasserthal Jakob, Zimmerer David, Petersen Jens, Kohl Simon,
|
|
17
|
+
Schock Justus, Klein Andre, Roß Tobias, Wirkert Sebastian, Neher Peter, Dinkelacker Stefan,
|
|
18
|
+
Köhler Gregor, Maier-Hein Klaus (2020). batchgenerators - a python framework for data
|
|
19
|
+
augmentation. doi:10.5281/zenodo.3632567
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
batchgenerators also contains the following application-specific augmentations:
|
|
23
|
+
* **Anatomy-informed Data Augmentation**
|
|
24
|
+
Proposed at [MICCAI 2023](https://arxiv.org/abs/2309.03652) for simulation of soft-tissue deformations. Implementation details can be found [here](https://github.com/MIC-DKFZ/anatomy_informed_DA).
|
|
25
|
+
* **Misalignment Data Augmentation**
|
|
26
|
+
Proposed in [Nature Scientific Reports 2023](https://www.nature.com/articles/s41598-023-46747-z)
|
|
27
|
+
for enhancing model's adaptability to diverse misalignments\
|
|
28
|
+
between multi-modal (multi-channel) images and thereby ensuring robust performance. Implementation details can be found [here](https://github.com/MIC-DKFZ/misalignment_DA).
|
|
29
|
+
|
|
30
|
+
If you use these augmentations please cite them too.
|
|
31
|
+
|
|
32
|
+
[](https://travis-ci.com/github/MIC-DKFZ/batchgenerators)
|
|
33
|
+
|
|
34
|
+
## Supported Augmentations
|
|
35
|
+
We supports a variety of augmentations, all of which are compatible with **2D and 3D input data**! (This is something
|
|
36
|
+
that was missing in most other frameworks).
|
|
37
|
+
|
|
38
|
+
* **Spatial Augmentations**
|
|
39
|
+
* mirroring
|
|
40
|
+
* channel translation (to simulate registration errors)
|
|
41
|
+
* elastic deformations
|
|
42
|
+
* rotations
|
|
43
|
+
* scaling
|
|
44
|
+
* resampling
|
|
45
|
+
* multi-channel misalignments
|
|
46
|
+
* **Color Augmentations**
|
|
47
|
+
* brightness (additive, multiplivative)
|
|
48
|
+
* contrast
|
|
49
|
+
* gamma (like gamma correction in photo editing)
|
|
50
|
+
* **Noise Augmentations**
|
|
51
|
+
* Gaussian Noise
|
|
52
|
+
* Rician Noise
|
|
53
|
+
* ...will be expanded in future commits
|
|
54
|
+
* **Cropping**
|
|
55
|
+
* random crop
|
|
56
|
+
* center crop
|
|
57
|
+
* padding
|
|
58
|
+
* **Anatomy-informed Augmentation**
|
|
59
|
+
|
|
60
|
+
Note: Stack transforms by using batchgenerators.transforms.abstract_transforms.Compose. Finish it up by plugging the
|
|
61
|
+
composed transform into our **multithreader**: batchgenerators.dataloading.multi_threaded_augmenter.MultiThreadedAugmenter
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## How to use it
|
|
65
|
+
|
|
66
|
+
The working principle is simple: Derive from DataLoaderBase class, reimplement generate_train_batch member function and
|
|
67
|
+
use it to stack your augmentations!
|
|
68
|
+
For simple example see `batchgenerators/examples/example_ipynb.ipynb`
|
|
69
|
+
|
|
70
|
+
A heavily commented example for using SlimDataLoaderBase and MultithreadedAugmentor is available at:
|
|
71
|
+
`batchgenerators/examples/multithreaded_with_batches.ipynb`.
|
|
72
|
+
It gives an idea of the interplay between the SlimDataLoaderBase and the MultiThreadedAugmentor.
|
|
73
|
+
The example uses the MultiThreadedAugmentor for loading and augmentation on mutiple processes, while
|
|
74
|
+
covering the entire dataset only once per epoch (basically sampling without replacement).
|
|
75
|
+
|
|
76
|
+
We also now have an extensive example for BraTS2017/2018 with both 2D and 3D DataLoader and augmentations:
|
|
77
|
+
`batchgenerators/examples/brats2017/`
|
|
78
|
+
|
|
79
|
+
There are also CIFAR10/100 datasets and DataLoader available at `batchgenerators/datasets/cifar.py`
|
|
80
|
+
|
|
81
|
+
## Data Structure
|
|
82
|
+
|
|
83
|
+
The data structure that is used internally (and with which you have to comply when implementing generate_train_batch)
|
|
84
|
+
is kept simple as well: It is just a regular python dictionary! We did this to allow maximum flexibility in the kind of
|
|
85
|
+
data that is passed along through the pipeline. The dictionary must have a 'data' key:value pair. It optionally can
|
|
86
|
+
handle a 'seg' key:vlaue pair to hold a segmentation. If a 'seg' key:value pair is present all spatial transformations
|
|
87
|
+
will also be applied to the segmentation! A part from 'data' and 'seg' you are free to do whatever you want (your image
|
|
88
|
+
classification/regression target for example). All key:value pairs other than 'data' and 'seg' will be passed through the
|
|
89
|
+
pipeline unmodified.
|
|
90
|
+
|
|
91
|
+
'data' value must have shape (b, c, x, y) for 2D or shape (b, c, x, y, z) for 3D!
|
|
92
|
+
'seg' value must have shape (b, c, x, y) for 2D or shape (b, c, x, y, z) for 3D! Color channel may be used here to
|
|
93
|
+
allow for several segmentation maps. If you have only one segmentation, make sure to have shape (b, 1, x, y (, z))
|
|
94
|
+
|
|
95
|
+
## How to install locally
|
|
96
|
+
|
|
97
|
+
Install batchgenerators
|
|
98
|
+
```
|
|
99
|
+
pip install --upgrade batchgenerators
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Import as follows
|
|
103
|
+
```
|
|
104
|
+
from batchgenerators.transforms.color_transforms import ContrastAugmentationTransform
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Windows Support is very experimental!
|
|
108
|
+
Batchgenerators makes heavy use of python multiprocessing and python multiprocessing on windows is different from linux.
|
|
109
|
+
To prevent the workers from freezing in windows, you have to guard your code with `if __name__ == '__main__'` and use multiprocessing's [`freeze_support`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support). The executed script may then look like this:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
# some imports and functions here
|
|
113
|
+
|
|
114
|
+
def main():
|
|
115
|
+
# do some stuff
|
|
116
|
+
|
|
117
|
+
if __name__ == '__main__':
|
|
118
|
+
from multiprocessing import freeze_support
|
|
119
|
+
freeze_support()
|
|
120
|
+
main()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This is not required on Linux.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## Release Notes
|
|
127
|
+
(only highlights, not an exhaustive list)
|
|
128
|
+
- 0.23.2:
|
|
129
|
+
- Misalignment data augmentation added
|
|
130
|
+
- 0.23.1:
|
|
131
|
+
- Anatomy-informed data augmentation added
|
|
132
|
+
- 0.23:
|
|
133
|
+
- fixed the import mess. `__init__.py` files are now empty. This is a breaking change for some users!
|
|
134
|
+
Please adapt your imports :-)
|
|
135
|
+
- local_transforms are now a thing, check them out!
|
|
136
|
+
- resize_segmentation now uses 'edge' mode and no longer takes a cval argument. Resizing segmentations with constant
|
|
137
|
+
border values (previous default) can cause problems and should not be done.
|
|
138
|
+
- 0.20.0:
|
|
139
|
+
- fixed an issue with MultiThreadedAugmenter not terminating properly after KeyboardInterrupt; Fixed an error
|
|
140
|
+
with the number and order of samples being returned when pin_memory=True; Improved performance by always hiding
|
|
141
|
+
process-process communication bottleneck through threading
|
|
142
|
+
- 0.19.5:
|
|
143
|
+
- fixed OMP_NUM_THREADS issue by using threadpoolctl package; dropped python 2 support (threadpoolctl is not
|
|
144
|
+
available for python 2)
|
|
145
|
+
- 0.19:
|
|
146
|
+
- There is now a complete example for BraTS2017/8 available for both 2D and 3D. Use this if you would like to get
|
|
147
|
+
some insights on how I (Fabian) do my experiments
|
|
148
|
+
- Windows is now supported! Thanks @justusschock for your support!
|
|
149
|
+
- new, simple parametrization of elastic deformation. Use SpatialTransform_2!
|
|
150
|
+
- CIFAR10/100 DataLoader are now available for your convenience
|
|
151
|
+
- a bug in MultiThreadedAugmenter that could interfere with reproducibility is now fixed
|
|
152
|
+
|
|
153
|
+
- 0.18:
|
|
154
|
+
- all augmentations (there are some exceptions though) are implemented on a per-sample basis. This should make it
|
|
155
|
+
easier to use the augmentations outside of the Transforms of batchgenerators
|
|
156
|
+
- applicable Transforms now have a keyword p_per_sample with which the user can specify a probability with which this
|
|
157
|
+
transform is applied to a sample. Before, this was handled by RndTransform and applied to the whole batch (so
|
|
158
|
+
either all samples were augmented or none). Now this decision is made on a per-sample basis and increases
|
|
159
|
+
variability by a lot.
|
|
160
|
+
- following the previous point, RndTransform is now deprecated
|
|
161
|
+
- AlternativeMultiThreadedAugmenter is now deprecated as well (no need to have this anymore)
|
|
162
|
+
- pytorch users can now transform numpy arrays to pytorch tensors within batchgenerators (NumpyToTensor). For some
|
|
163
|
+
reason, inter-process communication is faster with tensors (~factor 4), so this is recommended!
|
|
164
|
+
- if numpy arrays were converted to pytorch tensors, MultithreadedAugmenter now allows to pin the memory as well
|
|
165
|
+
(pin_memory=True). This will happen in a background thread (inspired by pytorch DataLoader). pinned memory can be
|
|
166
|
+
copied to the GPU much faster. My (Fabian) classification experiment with Resnet50 got a speed boost of 12% from just
|
|
167
|
+
that.
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
-------------------------
|
|
171
|
+
|
|
172
|
+
<img src="DKFZ_Logo.png" width="512px" />
|
|
173
|
+
|
|
174
|
+
<img src="HIP_Logo.png" width="512px" />
|
|
175
|
+
|
|
176
|
+
batchgenerators is developed by the [Division of Medical Image Computing](https://www.dkfz.de/en/mic/index.php) of the
|
|
177
|
+
German Cancer Research Center (DKFZ) and the Applied Computer Vision Lab (ACVL) of the
|
|
178
|
+
[Helmholtz Imaging Platform](https://helmholtz-imaging.de).
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import traceback
|
|
17
17
|
from copy import deepcopy
|
|
18
|
-
from typing import List, Union
|
|
18
|
+
from typing import List, Union, Callable
|
|
19
19
|
import threading
|
|
20
20
|
from builtins import range
|
|
21
21
|
from multiprocessing import Process
|
|
@@ -37,9 +37,15 @@ except ImportError:
|
|
|
37
37
|
|
|
38
38
|
def producer(queue: Queue, data_loader, transform, thread_id: int, seed,
|
|
39
39
|
abort_event: Event, wait_time: float = 0.02):
|
|
40
|
+
if torch is not None:
|
|
41
|
+
torch.set_num_threads(1)
|
|
42
|
+
if seed is not None:
|
|
43
|
+
torch.manual_seed(seed)
|
|
44
|
+
|
|
45
|
+
np.random.seed(seed)
|
|
46
|
+
|
|
40
47
|
# the producer will set the abort event if something happens
|
|
41
48
|
with threadpool_limits(1, None):
|
|
42
|
-
np.random.seed(seed)
|
|
43
49
|
data_loader.set_thread_id(thread_id)
|
|
44
50
|
item = None
|
|
45
51
|
|
|
@@ -139,7 +145,7 @@ class NonDetMultiThreadedAugmenter(object):
|
|
|
139
145
|
"""
|
|
140
146
|
|
|
141
147
|
def __init__(self, data_loader, transform, num_processes, num_cached=2, seeds=None, pin_memory=False,
|
|
142
|
-
wait_time=0.02):
|
|
148
|
+
wait_time=0.02, results_loop_fn: Callable = results_loop):
|
|
143
149
|
self.pin_memory = pin_memory
|
|
144
150
|
self.transform = transform
|
|
145
151
|
self.num_cached = num_cached
|
|
@@ -151,6 +157,7 @@ class NonDetMultiThreadedAugmenter(object):
|
|
|
151
157
|
|
|
152
158
|
self._queue = None
|
|
153
159
|
self._processes = []
|
|
160
|
+
self.results_loop_fn = results_loop
|
|
154
161
|
self.results_loop_thread = None
|
|
155
162
|
self.results_loop_queue = None
|
|
156
163
|
self.abort_event = None
|
|
@@ -208,18 +215,13 @@ class NonDetMultiThreadedAugmenter(object):
|
|
|
208
215
|
if isinstance(self.generator, DataLoader):
|
|
209
216
|
self.generator.was_initialized = False
|
|
210
217
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
)))
|
|
219
|
-
self._processes[-1].daemon = True
|
|
220
|
-
_ = [i.start() for i in self._processes]
|
|
221
|
-
if torch is not None:
|
|
222
|
-
torch.set_num_threads(torch_nthreads)
|
|
218
|
+
|
|
219
|
+
for i in range(self.num_processes):
|
|
220
|
+
self._processes.append(Process(target=producer, args=(
|
|
221
|
+
self._queue, self.generator, self.transform, i, self.seeds[i], self.abort_event, self.wait_time
|
|
222
|
+
)))
|
|
223
|
+
self._processes[-1].daemon = True
|
|
224
|
+
_ = [i.start() for i in self._processes]
|
|
223
225
|
|
|
224
226
|
if torch is not None and torch.cuda.is_available():
|
|
225
227
|
gpu = torch.cuda.current_device()
|
|
@@ -228,7 +230,7 @@ class NonDetMultiThreadedAugmenter(object):
|
|
|
228
230
|
|
|
229
231
|
# in_queue: Queue, out_queue: thrQueue, abort_event: Event, pin_memory: bool, worker_list: List[Process],
|
|
230
232
|
# gpu: Union[int, None] = None, wait_time: float = 0.02
|
|
231
|
-
self.results_loop_thread = threading.Thread(target=
|
|
233
|
+
self.results_loop_thread = threading.Thread(target=self.results_loop_fn, args=(
|
|
232
234
|
self._queue, self.results_loop_queue, self.abort_event, self.pin_memory, self._processes, gpu,
|
|
233
235
|
self.wait_time)
|
|
234
236
|
)
|