Apply a list of transforms sequentially.
| 273 | |
| 274 | |
| 275 | class TransformList(BaseTransform): |
| 276 | """ |
| 277 | Apply a list of transforms sequentially. |
| 278 | """ |
| 279 | def __init__(self, tfms): |
| 280 | """ |
| 281 | Args: |
| 282 | tfms (list[Transform]): |
| 283 | """ |
| 284 | for t in tfms: |
| 285 | assert isinstance(t, BaseTransform), t |
| 286 | self.tfms = tfms |
| 287 | |
| 288 | def _apply(self, x, meth): |
| 289 | for t in self.tfms: |
| 290 | x = getattr(t, meth)(x) |
| 291 | return x |
| 292 | |
| 293 | def __getattr__(self, name): |
| 294 | if name.startswith("apply_"): |
| 295 | return lambda x: self._apply(x, name) |
| 296 | raise AttributeError("TransformList object has no attribute {}".format(name)) |
| 297 | |
| 298 | def __str__(self): |
| 299 | repr_each_tfm = ",\n".join([" " + repr(x) for x in self.tfms]) |
| 300 | return "imgaug.TransformList([\n{}])".format(repr_each_tfm) |
| 301 | |
| 302 | def __add__(self, other): |
| 303 | other = other.tfms if isinstance(other, TransformList) else [other] |
| 304 | return TransformList(self.tfms + other) |
| 305 | |
| 306 | def __iadd__(self, other): |
| 307 | other = other.tfms if isinstance(other, TransformList) else [other] |
| 308 | self.tfms.extend(other) |
| 309 | return self |
| 310 | |
| 311 | def __radd__(self, other): |
| 312 | other = other.tfms if isinstance(other, TransformList) else [other] |
| 313 | return TransformList(other + self.tfms) |
| 314 | |
| 315 | __repr__ = __str__ |
| 316 | |
| 317 | |
| 318 | class LazyTransform(BaseTransform): |
no outgoing calls
no test coverage detected
searching dependent graphs…