Convert this augmenter from a stochastic to a deterministic one. A stochastic augmenter samples pseudo-random values for each parameter, image and batch. A deterministic augmenter also samples new values for each parameter and image, but not batch. Instead, for conse
(self, n=None)
| 2214 | ia.imshow(grid) |
| 2215 | |
| 2216 | def to_deterministic(self, n=None): |
| 2217 | """Convert this augmenter from a stochastic to a deterministic one. |
| 2218 | |
| 2219 | A stochastic augmenter samples pseudo-random values for each parameter, |
| 2220 | image and batch. |
| 2221 | A deterministic augmenter also samples new values for each parameter |
| 2222 | and image, but not batch. Instead, for consecutive batches it will |
| 2223 | sample the same values (provided the number of images and their sizes |
| 2224 | don't change). |
| 2225 | From a technical perspective this means that a deterministic augmenter |
| 2226 | starts each batch's augmentation with a random number generator in |
| 2227 | the same state (i.e. same seed), instead of advancing that state from |
| 2228 | batch to batch. |
| 2229 | |
| 2230 | Using determinism is useful to (a) get the same augmentations for |
| 2231 | two or more image batches (e.g. for stereo cameras), (b) to augment |
| 2232 | images and corresponding data on them (e.g. segmentation maps or |
| 2233 | bounding boxes) in the same way. |
| 2234 | |
| 2235 | Parameters |
| 2236 | ---------- |
| 2237 | n : None or int, optional |
| 2238 | Number of deterministic augmenters to return. |
| 2239 | If ``None`` then only one :class:`~imgaug.augmenters.meta.Augmenter` |
| 2240 | instance will be returned. |
| 2241 | If ``1`` or higher, a list containing ``n`` |
| 2242 | :class:`~imgaug.augmenters.meta.Augmenter` instances will be |
| 2243 | returned. |
| 2244 | |
| 2245 | Returns |
| 2246 | ------- |
| 2247 | imgaug.augmenters.meta.Augmenter or list of imgaug.augmenters.meta.Augmenter |
| 2248 | A single Augmenter object if `n` was None, |
| 2249 | otherwise a list of Augmenter objects (even if `n` was ``1``). |
| 2250 | |
| 2251 | """ |
| 2252 | assert n is None or n >= 1, ( |
| 2253 | "Expected 'n' to be None or >=1, got %s." % (n,)) |
| 2254 | if n is None: |
| 2255 | return self.to_deterministic(1)[0] |
| 2256 | return [self._to_deterministic() for _ in sm.xrange(n)] |
| 2257 | |
| 2258 | def _to_deterministic(self): |
| 2259 | """Convert this augmenter from a stochastic to a deterministic one. |