MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / TransformList

Class TransformList

tensorpack/dataflow/imgaug/transform.py:275–315  ·  view source on GitHub ↗

Apply a list of transforms sequentially.

Source from the content-addressed store, hash-verified

273
274
275class 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
318class LazyTransform(BaseTransform):

Callers 6

get_transformMethod · 0.85
get_transformMethod · 0.85
get_transformMethod · 0.85
get_transformMethod · 0.85
__add__Method · 0.85
__radd__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…