MCPcopy
hub / github.com/alibaba/EasyCV / randomGrayScale

Function randomGrayScale

easycv/utils/preprocess_function.py:165–177  ·  view source on GitHub ↗
(image, apply_prob=0.2)

Source from the content-addressed store, hash-verified

163
164
165def randomGrayScale(image, apply_prob=0.2):
166 expand_batch_dim = len(image.size()) == 3
167 if expand_batch_dim:
168 image = image.unsqueeze(0)
169 batch_size = image.size(0)
170 for index in range(batch_size):
171 if random.random() < apply_prob:
172 tmp = 0.299 * image[index, 0] + 0.587 * image[
173 index, 1] + 0.114 * image[index, 2]
174 image[index, 0] = tmp
175 image[index, 1] = tmp
176 image[index, 2] = tmp
177 return image
178
179
180def mixUp(image, alpha=0.2):

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
randomMethod · 0.45

Tested by

no test coverage detected