Applies RandomErasing to a single image. Args: probability: Probability of augmenting the image. Defaults to `0.25`. min_area: Minimum area of the random erasing rectangle. Defaults to `0.02`. max_area: Maximum area of the random erasing rectangle. Defaults to `1/3`.
(self,
probability: float = 0.25,
min_area: float = 0.02,
max_area: float = 1 / 3,
min_aspect: float = 0.3,
max_aspect: Optional[float] = None,
min_count=1,
max_count=1,
trials=10)
| 104 | """ |
| 105 | |
| 106 | def __init__(self, |
| 107 | probability: float = 0.25, |
| 108 | min_area: float = 0.02, |
| 109 | max_area: float = 1 / 3, |
| 110 | min_aspect: float = 0.3, |
| 111 | max_aspect: Optional[float] = None, |
| 112 | min_count=1, |
| 113 | max_count=1, |
| 114 | trials=10): |
| 115 | """Applies RandomErasing to a single image. |
| 116 | Args: |
| 117 | probability: Probability of augmenting the image. Defaults to `0.25`. |
| 118 | min_area: Minimum area of the random erasing rectangle. Defaults to |
| 119 | `0.02`. |
| 120 | max_area: Maximum area of the random erasing rectangle. Defaults to `1/3`. |
| 121 | min_aspect: Minimum aspect rate of the random erasing rectangle. Defaults |
| 122 | to `0.3`. |
| 123 | max_aspect: Maximum aspect rate of the random erasing rectangle. Defaults |
| 124 | to `None`. |
| 125 | min_count: Minimum number of erased rectangles. Defaults to `1`. |
| 126 | max_count: Maximum number of erased rectangles. Defaults to `1`. |
| 127 | trials: Maximum number of trials to randomly sample a rectangle that |
| 128 | fulfills constraint. Defaults to `10`. |
| 129 | """ |
| 130 | self._probability = probability |
| 131 | self._min_area = float(min_area) |
| 132 | self._max_area = float(max_area) |
| 133 | self._min_log_aspect = math.log(min_aspect) |
| 134 | self._max_log_aspect = math.log(max_aspect or 1 / min_aspect) |
| 135 | self._min_count = min_count |
| 136 | self._max_count = max_count |
| 137 | self._trials = trials |
| 138 | |
| 139 | def distort(self, image: tf.Tensor) -> tf.Tensor: |
| 140 | """Applies RandomErasing to single `image`. |
nothing calls this directly
no outgoing calls
no test coverage detected