(image, bboxes, seed=None)
return fix_image_flip_shape(image, result), bboxes
Randomly flips an image vertically (upside down).

    With a 1 in 2 chance, outputs the contents of `image` flipped along the first
    dimension, which is `height`.  Otherwise output the image as-is.

    Args:
    image: A 3-D tensor of shape `[height, width, channels].`
    seed: A Python integer. Used to create a random seed. See
      @{tf.set_random_seed}
      for behavior.

    Returns:
    A 3-D tensor of the same type and shape as `image`.

    Raises:
    ValueError: if the shape of `image` not supported.
Randomly flips an image vertically (upside down).
Randomly flips an image vertically ( upside down ) .
def random_flip_up_down(image, bboxes, seed=None):
    """Randomly flips an image vertically (upside down).

    With a 1 in 2 chance, outputs the contents of `image` flipped along the first
    dimension, which is `height`.  Otherwise output the image as-is.

    Args:
    image: A 3-D tensor of shape `[height, width, channels].`
    seed: A Python integer. Used to create a random seed. See
      @{tf.set_random_seed}
      for behavior.

    Returns:
    A 3-D tensor of the same type and shape as `image`.

    Raises:
    ValueError: if the shape of `image` not supported.
    """
    def flip_bboxes(bboxes):
        """Flip bounding boxes coordinates.
        """
        bboxes = tf.stack([1 - bboxes[:, 2], bboxes[:, 1],
                           1 - bboxes[:, 0], bboxes[:, 3]], axis=-1)
        return bboxes

    image = ops.convert_to_tensor(image, name='image')
    image = control_flow_ops.with_dependencies(
      _Check3DImage(image, require_static=False), image)
    uniform_random = random_ops.random_uniform([], 0, 1.0, seed=seed)
    mirror_cond = math_ops.less(uniform_random, .5)
    result = control_flow_ops.cond(mirror_cond,
                                 lambda: array_ops.reverse_v2(image, [0]),
                                 lambda: image)

    # Flip bboxes.
    bboxes = control_flow_ops.cond(mirror_cond,
                                   lambda: flip_bboxes(bboxes),
                                   lambda: bboxes)
    return fix_image_flip_shape(image, result), bboxes
def random_flip_up_down ( image , bboxes , seed = None ) : def flip_bboxes ( bboxes ) : """Flip bounding boxes coordinates.
        """ bboxes = tf . stack ( [ 1 - bboxes [ : , 2 ] , bboxes [ : , 1 ] , 1 - bboxes [ : , 0 ] , bboxes [ : , 3 ] ] , axis = - 1 ) return bboxes image = ops . convert_to_tensor ( image , name = 'image' ) image = control_flow_ops . with_dependencies ( _Check3DImage ( image , require_static = False ) , image ) uniform_random = random_ops . random_uniform ( [ ] , 0 , 1.0 , seed = seed ) mirror_cond = math_ops . less ( uniform_random , .5 ) result = control_flow_ops . cond ( mirror_cond , lambda : array_ops . reverse_v2 ( image , [ 0 ] ) , lambda : image ) # Flip bboxes. bboxes = control_flow_ops . cond ( mirror_cond , lambda : flip_bboxes ( bboxes ) , lambda : bboxes ) return fix_image_flip_shape ( image , result ) , bboxes