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

Class AugmentImageComponent

tensorpack/dataflow/image.py:85–122  ·  view source on GitHub ↗

Apply image augmentors on 1 image component.

Source from the content-addressed store, hash-verified

83
84
85class AugmentImageComponent(MapDataComponent):
86 """
87 Apply image augmentors on 1 image component.
88 """
89
90 def __init__(self, ds, augmentors, index=0, copy=True, catch_exceptions=False):
91 """
92 Args:
93 ds (DataFlow): input DataFlow.
94 augmentors (AugmentorList): a list of :class:`imgaug.ImageAugmentor` to be applied in order.
95 index (int or str): the index or key of the image component to be augmented in the datapoint.
96 copy (bool): Some augmentors modify the input images. When copy is
97 True, a copy will be made before any augmentors are applied,
98 to keep the original images not modified.
99 Turn it off to save time when you know it's OK.
100 catch_exceptions (bool): when set to True, will catch
101 all exceptions and only warn you when there are too many (>100).
102 Can be used to ignore occasion errors in data.
103 """
104 if isinstance(augmentors, AugmentorList):
105 self.augs = augmentors
106 else:
107 self.augs = AugmentorList(augmentors)
108 self._copy = copy
109
110 self._exception_handler = ExceptionHandler(catch_exceptions)
111 super(AugmentImageComponent, self).__init__(ds, self._aug_mapper, index)
112
113 def reset_state(self):
114 self.ds.reset_state()
115 self.augs.reset_state()
116
117 def _aug_mapper(self, x):
118 check_dtype(x)
119 with self._exception_handler.catch():
120 if self._copy:
121 x = copy_mod.deepcopy(x)
122 return self.augs.augment(x)
123
124
125class AugmentImageCoordinates(MapData):

Callers 15

get_imagenet_dataflowFunction · 0.90
get_imagenet_dataflowFunction · 0.90
get_imagenet_dataflowFunction · 0.90
get_imagenet_dataflowFunction · 0.90
get_dfFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85
get_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected