Perform data augmentation with random scaling & rotating.
(self, results)
| 185 | self.rot_prob = rot_prob |
| 186 | |
| 187 | def __call__(self, results): |
| 188 | """Perform data augmentation with random scaling & rotating.""" |
| 189 | s = results['scale'] |
| 190 | |
| 191 | sf = self.scale_factor |
| 192 | rf = self.rot_factor |
| 193 | |
| 194 | s_factor = np.clip(np.random.randn() * sf + 1, 1 - sf, 1 + sf) |
| 195 | s = s * s_factor |
| 196 | |
| 197 | r_factor = np.clip(np.random.randn() * rf, -rf * 2, rf * 2) |
| 198 | r = r_factor if np.random.rand() <= self.rot_prob else 0 |
| 199 | |
| 200 | results['scale'] = s |
| 201 | results['rotation'] = r |
| 202 | |
| 203 | return results |
| 204 | |
| 205 | class TopDownAffine: |
| 206 | """Affine transform the image to make input. |