Adaptive selects a channel or two channels. Args: probability: The probability that the Random Erasing operation will be performed. sl: Minimum proportion of erased area against input image. sh: Maximum proportion of erased area against input image. r1:
| 10 | |
| 11 | |
| 12 | class ChannelAdap(object): |
| 13 | """ Adaptive selects a channel or two channels. |
| 14 | Args: |
| 15 | probability: The probability that the Random Erasing operation will be performed. |
| 16 | sl: Minimum proportion of erased area against input image. |
| 17 | sh: Maximum proportion of erased area against input image. |
| 18 | r1: Minimum aspect ratio of erased area. |
| 19 | mean: Erasing value. |
| 20 | """ |
| 21 | |
| 22 | def __init__(self, probability = 0.5): |
| 23 | self.probability = probability |
| 24 | |
| 25 | |
| 26 | def __call__(self, img): |
| 27 | |
| 28 | # if random.uniform(0, 1) > self.probability: |
| 29 | # return img |
| 30 | |
| 31 | idx = random.randint(0, 3) |
| 32 | |
| 33 | if idx ==0: |
| 34 | # random select R Channel |
| 35 | img[1, :,:] = img[0,:,:] |
| 36 | img[2, :,:] = img[0,:,:] |
| 37 | elif idx ==1: |
| 38 | # random select B Channel |
| 39 | img[0, :,:] = img[1,:,:] |
| 40 | img[2, :,:] = img[1,:,:] |
| 41 | elif idx ==2: |
| 42 | # random select G Channel |
| 43 | img[0, :,:] = img[2,:,:] |
| 44 | img[1, :,:] = img[2,:,:] |
| 45 | else: |
| 46 | img = img |
| 47 | |
| 48 | return img |
| 49 | |
| 50 | |
| 51 | class ChannelAdapGray(object): |
nothing calls this directly
no outgoing calls
no test coverage detected