| 374 | |
| 375 | |
| 376 | class PhotometricDistort(object): |
| 377 | def __init__(self): |
| 378 | self.pd = [ |
| 379 | RandomContrast(), |
| 380 | ConvertColor(transform='HSV'), |
| 381 | RandomSaturation(), |
| 382 | RandomHue(), |
| 383 | ConvertColor(current='HSV', transform='BGR'), |
| 384 | RandomContrast() |
| 385 | ] |
| 386 | self.rand_brightness = RandomBrightness() |
| 387 | self.rand_light_noise = RandomLightingNoise() |
| 388 | |
| 389 | def __call__(self, image, boxes, labels): |
| 390 | im = image.copy() |
| 391 | im, boxes, labels = self.rand_brightness(im, boxes, labels) |
| 392 | if random.randint(2): |
| 393 | distort = Compose(self.pd[:-1]) |
| 394 | else: |
| 395 | distort = Compose(self.pd[1:]) |
| 396 | im, boxes, labels = distort(im, boxes, labels) |
| 397 | return self.rand_light_noise(im, boxes, labels) |
| 398 | |
| 399 | |
| 400 | class SSDAugmentation(object): |