outputs_first = segmaps
outputs_second = segmaps
for i, (outputs_first_i, outputs_second_i) in enumerate(zip(outputs_first, outputs_second)):
// Segmap augmentation also works channel-wise based on image
// channels, even though the channels have different meanings
// between images and segmaps. This is done in order to keep the
// random values properly synchronized with the image augmentation
if per_channel[i] > 0.5:
nb_channels_i = segmaps[i].shape[2] if len(segmaps[i].shape) >= 3 else 1
alpha = np.average(alphas[i, 0:nb_channels_i])
else:
alpha = alphas[i, 0]
assert 0 <= alpha <= 1.0, (
"Expected "alpha" to be in the interval [0.0, 1.0]. "
"Got %.4f." % (alpha,))
// We cant choose "just a bit" of one segmentation map augmentation
// result without messing up the positions (interpolation doesn"t
// make much sense here),
// so if the alpha is >= 0.5 (branch A is more visible than
// branch B), the result of branch A, otherwise branch B.
if alpha >= 0.5:
result[i] = outputs_first_i
else:
result[i] = outputs_second_i
After Change
outputs_first = segmaps
outputs_second = segmaps
gen = enumerate(zip(outputs_first, outputs_second))
for i, (outputs_first_i, outputs_second_i) in gen:
// Segmap augmentation also works channel-wise based on image
// channels, even though the channels have different meanings
// between images and segmaps. This is done in order to keep the
// random values properly synchronized with the image augmentation
if per_channel[i] > 0.5:
nb_channels_i = (
segmaps[i].shape[2] if len(segmaps[i].shape) >= 3 else 1)
alpha = np.average(alphas[i, 0:nb_channels_i])
else:
alpha = alphas[i, 0]
assert 0 <= alpha <= 1.0, (
"Expected "alpha" to be in the interval [0.0, 1.0]. "
"Got %.4f." % (alpha,))
// We cant choose "just a bit" of one segmentation map augmentation
// result without messing up the positions (interpolation doesn"t
// make much sense here),
// so if the alpha is >= 0.5 (branch A is more visible than
// branch B), the result of branch A, otherwise branch B.
if alpha >= 0.5:
result[i] = outputs_first_i
else:
result[i] = outputs_second_i