def flip_axis(x, axis, is_random=False):
 if is_random:
  factor = np.random.uniform((-1), 1)
  if (factor > 0):
   x = np.asarray(x).swapaxes(axis, 0)
   x = x[::(-1), ...]
   x = x.swapaxes(0, axis)
   return x
  else:
   return x
 else:
  x = np.asarray(x).swapaxes(axis, 0)
  x = x[::(-1), ...]
  x = x.swapaxes(0, axis)
  return x

def flip_axis ( x , axis , is_random = False ) : if is_random : factor = np . random . uniform ( ( - 1 ) , 1 ) if ( factor > 0 ) : x = np . asarray ( x ) . swapaxes ( axis , 0 ) x = x [ : : ( - 1 ) , ... ] x = x . swapaxes ( 0 , axis ) return x else : return x else : x = np . asarray ( x ) . swapaxes ( axis , 0 ) x = x [ : : ( - 1 ) , ... ] x = x . swapaxes ( 0 , axis ) return x
flip the axis of an image .