def translate_bbox(image, bboxes, pixels, replace, shift_horizontal):
    'Equivalent of PIL Translate in X/Y dimension that shifts image and bbox.\n\n  Args:\n    image: 3D uint8 Tensor.\n    bboxes: 2D Tensor that is a list of the bboxes in the image. Each bbox\n      has 4 elements (min_y, min_x, max_y, max_x) of type float with values\n      between [0, 1].\n    pixels: An int. How many pixels to shift the image and bboxes\n    replace: A one or three value 1D tensor to fill empty pixels.\n    shift_horizontal: Boolean. If true then shift in X dimension else shift in\n      Y dimension.\n\n  Returns:\n    A tuple containing a 3D uint8 Tensor that will be the result of translating\n    image by pixels. The second element of the tuple is bboxes, where now\n    the coordinates will be shifted to reflect the shifted image.\n  '
    if shift_horizontal:
        image = translate_x(image, pixels, replace)
    else:
        image = translate_y(image, pixels, replace)
    image_height = tf.shape(image)[0]
    image_width = tf.shape(image)[1]
    wrapped_shift_bbox = (lambda bbox: _shift_bbox(bbox, image_height, image_width, pixels, shift_horizontal))
    bboxes = tf.map_fn(wrapped_shift_bbox, bboxes)
    return (image, bboxes)
Equivalent of PIL Translate in X/Y dimension that shifts image and bbox.

Args:
  image: 3D uint8 Tensor.
  bboxes: 2D Tensor that is a list of the bboxes in the image. Each bbox
    has 4 elements (min_y, min_x, max_y, max_x) of type float with values
    between [0, 1].
  pixels: An int. How many pixels to shift the image and bboxes
  replace: A one or three value 1D tensor to fill empty pixels.
  shift_horizontal: Boolean. If true then shift in X dimension else shift in
    Y dimension.

Returns:
  A tuple containing a 3D uint8 Tensor that will be the result of translating
  image by pixels. The second element of the tuple is bboxes, where now
  the coordinates will be shifted to reflect the shifted image.
def translate_bbox(image, bboxes, pixels, replace, shift_horizontal):
    'Equivalent of PIL Translate in X/Y dimension that shifts image and bbox.\n\n  Args:\n    image: 3D uint8 Tensor.\n    bboxes: 2D Tensor that is a list of the bboxes in the image. Each bbox\n      has 4 elements (min_y, min_x, max_y, max_x) of type float with values\n      between [0, 1].\n    pixels: An int. How many pixels to shift the image and bboxes\n    replace: A one or three value 1D tensor to fill empty pixels.\n    shift_horizontal: Boolean. If true then shift in X dimension else shift in\n      Y dimension.\n\n  Returns:\n    A tuple containing a 3D uint8 Tensor that will be the result of translating\n    image by pixels. The second element of the tuple is bboxes, where now\n    the coordinates will be shifted to reflect the shifted image.\n  '
    if shift_horizontal:
        image = translate_x(image, pixels, replace)
    else:
        image = translate_y(image, pixels, replace)
    image_height = tf.shape(image)[0]
    image_width = tf.shape(image)[1]
    wrapped_shift_bbox = (lambda bbox: _shift_bbox(bbox, image_height, image_width, pixels, shift_horizontal))
    bboxes = tf.map_fn(wrapped_shift_bbox, bboxes)
    return (image, bboxes)