neulab/docprompting-conala huggingface dataset:
tf.image.image_gradients     View source on GitHub    Returns image gradients (dy, dx) for each color channel.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.image_gradients  
tf.image.image_gradients(
    image
)
 Both output tensors have the same shape as the input: [batch_size, h, w, d]. The gradient values are organized so that [I(x+1, y) - I(x, y)] is in location (x, y). That means that dy will always have zeros in the last row, and dx will always have zeros in the last column. Usage Example: BATCH_SIZE = 1
IMAGE_HEIGHT = 5
IMAGE_WIDTH = 5
CHANNELS = 1
image = tf.reshape(tf.range(IMAGE_HEIGHT * IMAGE_WIDTH * CHANNELS,
  delta=1, dtype=tf.float32),
  shape=(BATCH_SIZE, IMAGE_HEIGHT, IMAGE_WIDTH, CHANNELS))
dx, dy = tf.image.image_gradients(image)
print(image[0, :,:,0])
tf.Tensor(
  [[ 0.  1.  2.  3.  4.]
  [ 5.  6.  7.  8.  9.]
  [10. 11. 12. 13. 14.]
  [15. 16. 17. 18. 19.]
  [20. 21. 22. 23. 24.]], shape=(5, 5), dtype=float32)
print(dx[0, :,:,0])
tf.Tensor(
  [[5. 5. 5. 5. 5.]
  [5. 5. 5. 5. 5.]
  [5. 5. 5. 5. 5.]
  [5. 5. 5. 5. 5.]
  [0. 0. 0. 0. 0.]], shape=(5, 5), dtype=float32)
print(dy[0, :,:,0])
tf.Tensor(
  [[1. 1. 1. 1. 0.]
  [1. 1. 1. 1. 0.]
  [1. 1. 1. 1. 0.]
  [1. 1. 1. 1. 0.]
  [1. 1. 1. 1. 0.]], shape=(5, 5), dtype=float32)

 


 Arguments
  image   Tensor with shape [batch_size, h, w, d].   
 


 Returns   Pair of tensors (dy, dx) holding the vertical and horizontal image gradients (1-step finite difference).  

 


 Raises
  ValueError   If image is not a 4D tensor.
tf.image.non_max_suppression     View source on GitHub    Greedily selects a subset of bounding boxes in descending order of score.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.non_max_suppression  
tf.image.non_max_suppression(
    boxes, scores, max_output_size, iou_threshold=0.5,
    score_threshold=float('-inf'), name=None
)
 Prunes away boxes that have high intersection-over-union (IOU) overlap with previously selected boxes. Bounding boxes are supplied as [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any diagonal pair of box corners and the coordinates can be provided as normalized (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm is agnostic to where the origin is in the coordinate system. Note that this algorithm is invariant to orthogonal transformations and translations of the coordinate system; thus translating or reflections of the coordinate system result in the same boxes being selected by the algorithm. The output of this operation is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the tf.gather operation. For example: selected_indices = tf.image.non_max_suppression(
    boxes, scores, max_output_size, iou_threshold)
selected_boxes = tf.gather(boxes, selected_indices)

 


 Args
  boxes   A 2-D float Tensor of shape [num_boxes, 4].  
  scores   A 1-D float Tensor of shape [num_boxes] representing a single score corresponding to each box (each row of boxes).  
  max_output_size   A scalar integer Tensor representing the maximum number of boxes to be selected by non-max suppression.  
  iou_threshold   A float representing the threshold for deciding whether boxes overlap too much with respect to IOU.  
  score_threshold   A float representing the threshold for deciding when to remove boxes based on score.  
  name   A name for the operation (optional).   
 


 Returns
  selected_indices   A 1-D integer Tensor of shape [M] representing the selected indices from the boxes tensor, where M <= max_output_size.
tf.image.non_max_suppression_overlaps     View source on GitHub    Greedily selects a subset of bounding boxes in descending order of score.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.non_max_suppression_overlaps  
tf.image.non_max_suppression_overlaps(
    overlaps, scores, max_output_size, overlap_threshold=0.5,
    score_threshold=float('-inf'), name=None
)
 Prunes away boxes that have high overlap with previously selected boxes. N-by-n overlap values are supplied as square matrix. The output of this operation is a set of integers indexing into the input collection of bounding boxes representing the selected boxes. The bounding box coordinates corresponding to the selected indices can then be obtained using the tf.gather operation. For example: selected_indices = tf.image.non_max_suppression_overlaps(
    overlaps, scores, max_output_size, iou_threshold)
selected_boxes = tf.gather(boxes, selected_indices)

 


 Args
  overlaps   A 2-D float Tensor of shape [num_boxes, num_boxes].  
  scores   A 1-D float Tensor of shape [num_boxes] representing a single score corresponding to each box (each row of boxes).  
  max_output_size   A scalar integer Tensor representing the maximum number of boxes to be selected by non-max suppression.  
  overlap_threshold   A float representing the threshold for deciding whether boxes overlap too much with respect to the provided overlap values.  
  score_threshold   A float representing the threshold for deciding when to remove boxes based on score.  
  name   A name for the operation (optional).   
 


 Returns
  selected_indices   A 1-D integer Tensor of shape [M] representing the selected indices from the overlaps tensor, where M <= max_output_size.
tf.image.pad_to_bounding_box     View source on GitHub    Pad image with zeros to the specified height and width.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.pad_to_bounding_box  
tf.image.pad_to_bounding_box(
    image, offset_height, offset_width, target_height, target_width
)
 Adds offset_height rows of zeros on top, offset_width columns of zeros on the left, and then pads the image on the bottom and right with zeros until it has dimensions target_height, target_width. This op does nothing if offset_* is zero and the image already has size target_height by target_width. Usage Example: 
x = [[[1., 2., 3.],
      [4., 5., 6.]],
      [[7., 8., 9.],
      [10., 11., 12.]]]
padded_image = tf.image.pad_to_bounding_box(x, 1, 1, 4, 4)
padded_image
<tf.Tensor: shape=(4, 4, 3), dtype=float32, numpy=
array([[[ 0.,  0.,  0.],
[ 0.,  0.,  0.],
[ 0.,  0.,  0.],
[ 0.,  0.,  0.]],
[[ 0.,  0.,  0.],
[ 1.,  2.,  3.],
[ 4.,  5.,  6.],
[ 0.,  0.,  0.]],
[[ 0.,  0.,  0.],
[ 7.,  8.,  9.],
[10., 11., 12.],
[ 0.,  0.,  0.]],
[[ 0.,  0.,  0.],
[ 0.,  0.,  0.],
[ 0.,  0.,  0.],
[ 0.,  0.,  0.]]], dtype=float32)>

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  offset_height   Number of rows of zeros to add on top.  
  offset_width   Number of columns of zeros to add on the left.  
  target_height   Height of output image.  
  target_width   Width of output image.   
 


 Returns   If image was 4-D, a 4-D float Tensor of shape [batch, target_height, target_width, channels] If image was 3-D, a 3-D float Tensor of shape [target_height, target_width, channels]  

 


 Raises
  ValueError   If the shape of image is incompatible with the offset_* or target_* arguments, or either offset_height or offset_width is negative.
tf.image.per_image_standardization     View source on GitHub    Linearly scales each image in image to have mean 0 and variance 1.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.per_image_standardization  
tf.image.per_image_standardization(
    image
)
 For each 3-D image x in image, computes (x - mean) / adjusted_stddev, where  
mean is the average of all values in x
 
adjusted_stddev = max(stddev, 1.0/sqrt(N)) is capped away from 0 to protect against division by 0 when handling uniform images  
N is the number of elements in x
 
stddev is the standard deviation of all values in x
 
 
 


 Args
  image   An n-D Tensor with at least 3 dimensions, the last 3 of which are the dimensions of each image.   
 


 Returns   A Tensor with the same shape and dtype as image.  

 


 Raises
  ValueError   if the shape of 'image' is incompatible with this function.
tf.image.psnr     View source on GitHub    Returns the Peak Signal-to-Noise Ratio between a and b.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.psnr  
tf.image.psnr(
    a, b, max_val, name=None
)
 This is intended to be used on signals (or images). Produces a PSNR value for each image in batch. The last three dimensions of input are expected to be [height, width, depth]. Example: # Read images from file.
im1 = tf.decode_png('path/to/im1.png')
im2 = tf.decode_png('path/to/im2.png')
# Compute PSNR over tf.uint8 Tensors.
psnr1 = tf.image.psnr(im1, im2, max_val=255)

# Compute PSNR over tf.float32 Tensors.
im1 = tf.image.convert_image_dtype(im1, tf.float32)
im2 = tf.image.convert_image_dtype(im2, tf.float32)
psnr2 = tf.image.psnr(im1, im2, max_val=1.0)
# psnr1 and psnr2 both have type tf.float32 and are almost equal.

 


 Arguments
  a   First set of images.  
  b   Second set of images.  
  max_val   The dynamic range of the images (i.e., the difference between the maximum the and minimum allowed values).  
  name   Namespace to embed the computation in.   
 


 Returns   The scalar PSNR between a and b. The returned tensor has type tf.float32 and shape [batch_size, 1].
tf.image.random_brightness     View source on GitHub    Adjust the brightness of images by a random factor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_brightness  
tf.image.random_brightness(
    image, max_delta, seed=None
)
 Equivalent to adjust_brightness() using a delta randomly picked in the interval [-max_delta, max_delta).
 


 Args
  image   An image or images to adjust.  
  max_delta   float, must be non-negative.  
  seed   A Python integer. Used to create a random seed. See tf.compat.v1.set_random_seed for behavior.    Usage Example: 
x = [[[1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0]],
     [[7.0, 8.0, 9.0],
      [10.0, 11.0, 12.0]]]
tf.image.random_brightness(x, 0.2)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=...>

 


 Returns   The brightness-adjusted image(s).  

 


 Raises
  ValueError   if max_delta is negative.
tf.image.random_contrast     View source on GitHub    Adjust the contrast of an image or images by a random factor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_contrast  
tf.image.random_contrast(
    image, lower, upper, seed=None
)
 Equivalent to adjust_contrast() but uses a contrast_factor randomly picked in the interval [lower, upper).
 


 Args
  image   An image tensor with 3 or more dimensions.  
  lower   float. Lower bound for the random contrast factor.  
  upper   float. Upper bound for the random contrast factor.  
  seed   A Python integer. Used to create a random seed. See tf.compat.v1.set_random_seed for behavior.    Usage Example: 
x = [[[1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0],
      [10.0, 11.0, 12.0]]]
tf.image.random_contrast(x, 0.2, 0.5)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=...>

 


 Returns   The contrast-adjusted image(s).  

 


 Raises
  ValueError   if upper <= lower or if lower < 0.
tf.image.random_crop     View source on GitHub    Randomly crops a tensor to a given size.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_crop, tf.compat.v1.random_crop  
tf.image.random_crop(
    value, size, seed=None, name=None
)
 Slices a shape size portion out of value at a uniformly chosen offset. Requires value.shape >= size. If a dimension should not be cropped, pass the full size of that dimension. For example, RGB images can be cropped with size = [crop_height, crop_width, 3].
 


 Args
  value   Input tensor to crop.  
  size   1-D tensor with size the rank of value.  
  seed   Python integer. Used to create a random seed. See tf.random.set_seed for behavior.  
  name   A name for this operation (optional).   
 


 Returns   A cropped tensor of the same rank as value and shape size.
tf.image.random_flip_left_right     View source on GitHub    Randomly flip an image horizontally (left to right).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_flip_left_right  
tf.image.random_flip_left_right(
    image, seed=None
)
 With a 1 in 2 chance, outputs the contents of image flipped along the second dimension, which is width. Otherwise output the image as-is. When passing a batch of images, each image will be randomly flipped independent of other images. Example usage: 
image = np.array([[[1], [2]], [[3], [4]]])
tf.image.random_flip_left_right(image, 5).numpy().tolist()
[[[2], [1]], [[4], [3]]]
 Randomly flip multiple images. 
images = np.array(
[
    [[[1], [2]], [[3], [4]]],
    [[[5], [6]], [[7], [8]]]
])
tf.image.random_flip_left_right(images, 6).numpy().tolist()
[[[[2], [1]], [[4], [3]]], [[[5], [6]], [[7], [8]]]]

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  seed   A Python integer. Used to create a random seed. See tf.compat.v1.set_random_seed for behavior.   
 


 Returns   A tensor of the same type and shape as image.  

 


 Raises
  ValueError   if the shape of image not supported.
tf.image.random_flip_up_down     View source on GitHub    Randomly flips an image vertically (upside down).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_flip_up_down  
tf.image.random_flip_up_down(
    image, seed=None
)
 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. When passing a batch of images, each image will be randomly flipped independent of other images. Example usage: 
image = np.array([[[1], [2]], [[3], [4]]])
tf.image.random_flip_up_down(image, 3).numpy().tolist()
[[[3], [4]], [[1], [2]]]
 Randomly flip multiple images. 
images = np.array(
[
    [[[1], [2]], [[3], [4]]],
    [[[5], [6]], [[7], [8]]]
])
tf.image.random_flip_up_down(images, 4).numpy().tolist()
[[[[3], [4]], [[1], [2]]], [[[5], [6]], [[7], [8]]]]

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  seed   A Python integer. Used to create a random seed. See tf.compat.v1.set_random_seed for behavior.   
 


 Returns   A tensor of the same type and shape as image.  

 


 Raises
  ValueError   if the shape of image not supported.
tf.image.random_hue     View source on GitHub    Adjust the hue of RGB images by a random factor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_hue  
tf.image.random_hue(
    image, max_delta, seed=None
)
 Equivalent to adjust_hue() but uses a delta randomly picked in the interval [-max_delta, max_delta). max_delta must be in the interval [0, 0.5]. Usage Example: 
x = [[[1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0],
      [10.0, 11.0, 12.0]]]
tf.image.random_hue(x, 0.2)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=...>

 


 Args
  image   RGB image or images. The size of the last dimension must be 3.  
  max_delta   float. The maximum value for the random delta.  
  seed   An operation-specific seed. It will be used in conjunction with the graph-level seed to determine the real seeds that will be used in this operation. Please see the documentation of set_random_seed for its interaction with the graph-level random seed.   
 


 Returns   Adjusted image(s), same shape and DType as image.  

 


 Raises
  ValueError   if max_delta is invalid.
tf.image.random_jpeg_quality     View source on GitHub    Randomly changes jpeg encoding quality for inducing jpeg noise.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_jpeg_quality  
tf.image.random_jpeg_quality(
    image, min_jpeg_quality, max_jpeg_quality, seed=None
)
 min_jpeg_quality must be in the interval [0, 100] and less than max_jpeg_quality. max_jpeg_quality must be in the interval [0, 100]. Usage Example: 
x = [[[1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0],
      [10.0, 11.0, 12.0]]]
tf.image.random_jpeg_quality(x, 75, 95)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=...>

 


 Args
  image   3D image. Size of the last dimension must be 1 or 3.  
  min_jpeg_quality   Minimum jpeg encoding quality to use.  
  max_jpeg_quality   Maximum jpeg encoding quality to use.  
  seed   An operation-specific seed. It will be used in conjunction with the graph-level seed to determine the real seeds that will be used in this operation. Please see the documentation of set_random_seed for its interaction with the graph-level random seed.   
 


 Returns   Adjusted image(s), same shape and DType as image.  

 


 Raises
  ValueError   if min_jpeg_quality or max_jpeg_quality is invalid.
tf.image.random_saturation     View source on GitHub    Adjust the saturation of RGB images by a random factor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.random_saturation  
tf.image.random_saturation(
    image, lower, upper, seed=None
)
 Equivalent to adjust_saturation() but uses a saturation_factor randomly picked in the interval [lower, upper). Usage Example: 
x = [[[1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0]],
    [[7.0, 8.0, 9.0],
      [10.0, 11.0, 12.0]]]
tf.image.random_saturation(x, 5, 10)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 0. ,  1.5,  3. ],
        [ 0. ,  3. ,  6. ]],
       [[ 0. ,  4.5,  9. ],
        [ 0. ,  6. , 12. ]]], dtype=float32)>

 


 Args
  image   RGB image or images. The size of the last dimension must be 3.  
  lower   float. Lower bound for the random saturation factor.  
  upper   float. Upper bound for the random saturation factor.  
  seed   An operation-specific seed. It will be used in conjunction with the graph-level seed to determine the real seeds that will be used in this operation. Please see the documentation of set_random_seed for its interaction with the graph-level random seed.   
 


 Returns   Adjusted image(s), same shape and DType as image.  

 


 Raises
  ValueError   if upper <= lower or if lower < 0.
tf.image.ResizeMethod     View source on GitHub    See tf.image.resize for details.
 


 Class Variables
  AREA   'area'  
  BICUBIC   'bicubic'  
  BILINEAR   'bilinear'  
  GAUSSIAN   'gaussian'  
  LANCZOS3   'lanczos3'  
  LANCZOS5   'lanczos5'  
  MITCHELLCUBIC   'mitchellcubic'  
  NEAREST_NEIGHBOR   'nearest'
tf.image.resize_with_crop_or_pad     View source on GitHub    Crops and/or pads an image to a target width and height.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.resize_image_with_crop_or_pad, tf.compat.v1.image.resize_with_crop_or_pad  
tf.image.resize_with_crop_or_pad(
    image, target_height, target_width
)
 Resizes an image to a target width and height by either centrally cropping the image or padding it evenly with zeros. If width or height is greater than the specified target_width or target_height respectively, this op centrally crops along that dimension. If width or height is smaller than the specified target_width or target_height respectively, this op centrally pads with 0 along that dimension.
 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  target_height   Target height.  
  target_width   Target width.   
 


 Raises
  ValueError   if target_height or target_width are zero or negative.   
 


 Returns   Cropped and/or padded image. If images was 4-D, a 4-D float Tensor of shape [batch, new_height, new_width, channels]. If images was 3-D, a 3-D float Tensor of shape [new_height, new_width, channels].
tf.image.resize_with_pad Resizes and pads an image to a target width and height. 
tf.image.resize_with_pad(
    image, target_height, target_width, method=ResizeMethod.BILINEAR,
    antialias=False
)
 Resizes an image to a target width and height by keeping the aspect ratio the same without distortion. If the target dimensions don't match the image dimensions, the image is resized and then padded with zeroes to match requested dimensions.
 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  target_height   Target height.  
  target_width   Target width.  
  method   Method to use for resizing image. See image.resize()  
  antialias   Whether to use anti-aliasing when resizing. See 'image.resize()'.   
 


 Raises
  ValueError   if target_height or target_width are zero or negative.   
 


 Returns   Resized and padded image. If images was 4-D, a 4-D float Tensor of shape [batch, new_height, new_width, channels]. If images was 3-D, a 3-D float Tensor of shape [new_height, new_width, channels].
tf.image.rgb_to_grayscale     View source on GitHub    Converts one or more images from RGB to Grayscale.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.rgb_to_grayscale  
tf.image.rgb_to_grayscale(
    images, name=None
)
 Outputs a tensor of the same DType and rank as images. The size of the last dimension of the output is 1, containing the Grayscale value of the pixels. 
original = tf.constant([[[1.0, 2.0, 3.0]]])
converted = tf.image.rgb_to_grayscale(original)
print(converted.numpy())
[[[1.81...]]]

 


 Args
  images   The RGB tensor to convert. The last dimension must have size 3 and should contain RGB values.  
  name   A name for the operation (optional).   
 


 Returns   The converted grayscale image(s).
tf.image.rgb_to_hsv Converts one or more images from RGB to HSV.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.rgb_to_hsv  
tf.image.rgb_to_hsv(
    images, name=None
)
 Outputs a tensor of the same shape as the images tensor, containing the HSV value of the pixels. The output is only well defined if the value in images are in [0,1]. output[..., 0] contains hue, output[..., 1] contains saturation, and output[..., 2] contains value. All HSV values are in [0,1]. A hue of 0 corresponds to pure red, hue 1/3 is pure green, and 2/3 is pure blue. Usage Example: 
blue_image = tf.stack([
   tf.zeros([5,5]),
   tf.zeros([5,5]),
   tf.ones([5,5])],
   axis=-1)
blue_hsv_image = tf.image.rgb_to_hsv(blue_image)
blue_hsv_image[0,0].numpy()
array([0.6666667, 1. , 1. ], dtype=float32)

 


 Args
  images   A Tensor. Must be one of the following types: half, bfloat16, float32, float64. 1-D or higher rank. RGB data to convert. Last dimension must be size 3.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as images.
tf.image.rgb_to_yiq     View source on GitHub    Converts one or more images from RGB to YIQ.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.rgb_to_yiq  
tf.image.rgb_to_yiq(
    images
)
 Outputs a tensor of the same shape as the images tensor, containing the YIQ value of the pixels. The output is only well defined if the value in images are in [0,1]. Usage Example: 
x = tf.constant([[[1.0, 2.0, 3.0]]])
tf.image.rgb_to_yiq(x)
<tf.Tensor: shape=(1, 1, 3), dtype=float32,
numpy=array([[[ 1.815     , -0.91724455,  0.09962624]]], dtype=float32)>

 


 Args
  images   2-D or higher rank. Image data to convert. Last dimension must be size 3.   
 


 Returns
  images   tensor with the same shape as images.