neulab/docprompting-conala huggingface dataset:
tf.image.rgb_to_yuv     View source on GitHub    Converts one or more images from RGB to YUV.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.rgb_to_yuv  
tf.image.rgb_to_yuv(
    images
)
 Outputs a tensor of the same shape as the images tensor, containing the YUV value of the pixels. The output is only well defined if the value in images are in [0, 1]. There are two ways of representing an image: [0, 255] pixel values range or 0, 1 pixel values range. Users need to convert the input image into a float [0, 1] range.
 


 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.
tf.image.rot90     View source on GitHub    Rotate image(s) counter-clockwise by 90 degrees.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.rot90  
tf.image.rot90(
    image, k=1, name=None
)
 For example: 
a=tf.constant([[[1],[2]],
               [[3],[4]]])
# rotating `a` counter clockwise by 90 degrees
a_rot=tf.image.rot90(a)
print(a_rot[...,0].numpy())
[[2 4]
 [1 3]]
# rotating `a` counter clockwise by 270 degrees
a_rot=tf.image.rot90(a, k=3)
print(a_rot[...,0].numpy())
[[3 1]
 [4 2]]

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  k   A scalar integer. The number of times the image is rotated by 90 degrees.  
  name   A name for this operation (optional).   
 


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

 


 Raises
  ValueError   if the shape of image not supported.
tf.image.sobel_edges     View source on GitHub    Returns a tensor holding Sobel edge maps.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.sobel_edges  
tf.image.sobel_edges(
    image
)

 


 Arguments
  image   Image tensor with shape [batch_size, h, w, d] and type float32 or float64. The image(s) must be 2x2 or larger.   
 


 Returns   Tensor holding edge maps for each channel. Returns a tensor with shape [batch_size, h, w, d, 2] where the last two dimensions hold [[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1], dx[d-1]]] calculated using the Sobel filter.
tf.image.ssim     View source on GitHub    Computes SSIM index between img1 and img2.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.ssim  
tf.image.ssim(
    img1, img2, max_val, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03
)
 This function is based on the standard SSIM implementation from: Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E. P. (2004). Image quality assessment: from error visibility to structural similarity. IEEE transactions on image processing. 
Note: The true SSIM is only defined on grayscale. This function does not perform any colorspace transform. (If the input is already YUV, then it will compute YUV SSIM average.)
 Details:  11x11 Gaussian filter of width 1.5 is used. k1 = 0.01, k2 = 0.03 as in the original paper.  The image sizes must be at least 11x11 because of the filter size. Example: # Read images from file.
im1 = tf.decode_png('path/to/im1.png')
im2 = tf.decode_png('path/to/im2.png')
# Compute SSIM over tf.uint8 Tensors.
ssim1 = tf.image.ssim(im1, im2, max_val=255, filter_size=11,
                      filter_sigma=1.5, k1=0.01, k2=0.03)

# Compute SSIM over tf.float32 Tensors.
im1 = tf.image.convert_image_dtype(im1, tf.float32)
im2 = tf.image.convert_image_dtype(im2, tf.float32)
ssim2 = tf.image.ssim(im1, im2, max_val=1.0, filter_size=11,
                      filter_sigma=1.5, k1=0.01, k2=0.03)
# ssim1 and ssim2 both have type tf.float32 and are almost equal.

 


 Args
  img1   First image batch.  
  img2   Second image batch.  
  max_val   The dynamic range of the images (i.e., the difference between the maximum the and minimum allowed values).  
  filter_size   Default value 11 (size of gaussian filter).  
  filter_sigma   Default value 1.5 (width of gaussian filter).  
  k1   Default value 0.01  
  k2   Default value 0.03 (SSIM is less sensitivity to K2 for lower values, so it would be better if we took the values in the range of 0 < K2 < 0.4).   
 


 Returns   A tensor containing an SSIM value for each image in batch. Returned SSIM values are in range (-1, 1], when pixel values are non-negative. Returns a tensor with shape: broadcast(img1.shape[:-3], img2.shape[:-3]).
tf.image.ssim_multiscale     View source on GitHub    Computes the MS-SSIM between img1 and img2.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.ssim_multiscale  
tf.image.ssim_multiscale(
    img1, img2, max_val, power_factors=_MSSSIM_WEIGHTS, filter_size=11,
    filter_sigma=1.5, k1=0.01, k2=0.03
)
 This function assumes that img1 and img2 are image batches, i.e. the last three dimensions are [height, width, channels]. 
Note: The true SSIM is only defined on grayscale. This function does not perform any colorspace transform. (If the input is already YUV, then it will compute YUV SSIM average.)
 Original paper: Wang, Zhou, Eero P. Simoncelli, and Alan C. Bovik. "Multiscale structural similarity for image quality assessment." Signals, Systems and Computers, 2004.
 


 Arguments
  img1   First image batch.  
  img2   Second image batch. Must have the same rank as img1.  
  max_val   The dynamic range of the images (i.e., the difference between the maximum the and minimum allowed values).  
  power_factors   Iterable of weights for each of the scales. The number of scales used is the length of the list. Index 0 is the unscaled resolution's weight and each increasing scale corresponds to the image being downsampled by 2. Defaults to (0.0448, 0.2856, 0.3001, 0.2363, 0.1333), which are the values obtained in the original paper.  
  filter_size   Default value 11 (size of gaussian filter).  
  filter_sigma   Default value 1.5 (width of gaussian filter).  
  k1   Default value 0.01  
  k2   Default value 0.03 (SSIM is less sensitivity to K2 for lower values, so it would be better if we took the values in the range of 0 < K2 < 0.4).   
 


 Returns   A tensor containing an MS-SSIM value for each image in batch. The values are in range [0, 1]. Returns a tensor with shape: broadcast(img1.shape[:-3], img2.shape[:-3]).
tf.image.stateless_random_brightness Adjust the brightness of images by a random factor deterministically. 
tf.image.stateless_random_brightness(
    image, max_delta, seed
)
 Equivalent to adjust_brightness() using a delta randomly picked in the interval [-max_delta, max_delta). Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). 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]]]
seed = (1, 2)
tf.image.stateless_random_brightness(x, 0.2, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 1.1376241,  2.1376243,  3.1376243],
        [ 4.1376243,  5.1376243,  6.1376243]],
       [[ 7.1376243,  8.137624 ,  9.137624 ],
        [10.137624 , 11.137624 , 12.137624 ]]], dtype=float32)>

 


 Args
  image   An image or images to adjust.  
  max_delta   float, must be non-negative.  
  seed   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


 Returns   The brightness-adjusted image(s).  

 


 Raises
  ValueError   if max_delta is negative.
tf.image.stateless_random_contrast Adjust the contrast of images by a random factor deterministically. 
tf.image.stateless_random_contrast(
    image, lower, upper, seed
)
 Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed).
 


 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 shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)    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]]]
seed = (1, 2)
tf.image.stateless_random_contrast(x, 0.2, 0.5, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[3.4605184, 4.4605184, 5.4605184],
        [4.820173 , 5.820173 , 6.820173 ]],
       [[6.179827 , 7.179827 , 8.179828 ],
        [7.5394816, 8.539482 , 9.539482 ]]], dtype=float32)>

 


 Returns   The contrast-adjusted image(s).  

 


 Raises
  ValueError   if upper <= lower or if lower < 0.
tf.image.stateless_random_crop Randomly crops a tensor to a given size in a deterministic manner. 
tf.image.stateless_random_crop(
    value, size, seed, 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]. Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). Usage Example: 
image = [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]
seed = (1, 2)
tf.image.stateless_random_crop(value=image, size=(1, 2, 3), seed=seed)
<tf.Tensor: shape=(1, 2, 3), dtype=int32, numpy=
array([[[1, 2, 3],
        [4, 5, 6]]], dtype=int32)>

 


 Args
  value   Input tensor to crop.  
  size   1-D tensor with size the rank of value.  
  seed   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)  
  name   A name for this operation (optional).   
 


 Returns   A cropped tensor of the same rank as value and shape size.
tf.image.stateless_random_flip_left_right Randomly flip an image horizontally (left to right) deterministically. 
tf.image.stateless_random_flip_left_right(
    image, seed
)
 Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). Example usage: 
image = np.array([[[1], [2]], [[3], [4]]])
seed = (2, 3)
tf.image.stateless_random_flip_left_right(image, seed).numpy().tolist()
[[[2], [1]], [[4], [3]]]

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  seed   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


 Returns   A tensor of the same type and shape as image.
tf.image.stateless_random_flip_up_down Randomly flip an image vertically (upside down) deterministically. 
tf.image.stateless_random_flip_up_down(
    image, seed
)
 Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). Example usage: 
image = np.array([[[1], [2]], [[3], [4]]])
seed = (2, 3)
tf.image.stateless_random_flip_up_down(image, seed).numpy().tolist()
[[[3], [4]], [[1], [2]]]

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  seed   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


 Returns   A tensor of the same type and shape as image.
tf.image.stateless_random_hue Adjust the hue of RGB images by a random factor deterministically. 
tf.image.stateless_random_hue(
    image, max_delta, seed
)
 Equivalent to adjust_hue() but uses a delta randomly picked in the interval [-max_delta, max_delta). Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). 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]]]
seed = (1, 2)
tf.image.stateless_random_hue(x, 0.2, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 1.6514902,  1.       ,  3.       ],
        [ 4.65149  ,  4.       ,  6.       ]],
       [[ 7.65149  ,  7.       ,  9.       ],
        [10.65149  , 10.       , 12.       ]]], dtype=float32)>

 


 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   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


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

 


 Raises
  ValueError   if max_delta is invalid.
tf.image.stateless_random_jpeg_quality Deterministically radomize jpeg encoding quality for inducing jpeg noise. 
tf.image.stateless_random_jpeg_quality(
    image, min_jpeg_quality, max_jpeg_quality, seed
)
 Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). 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, 2, 3],
      [4, 5, 6]],
     [[7, 8, 9],
      [10, 11, 12]]]
x_uint8 = tf.cast(x, tf.uint8)
seed = (1, 2)
tf.image.stateless_random_jpeg_quality(x_uint8, 75, 95, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=uint8, numpy=
array([[[ 0,  4,  5],
        [ 1,  5,  6]],
       [[ 5,  9, 10],
        [ 5,  9, 10]]], dtype=uint8)>

 


 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   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


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

 


 Raises
  ValueError   if min_jpeg_quality or max_jpeg_quality is invalid.
tf.image.stateless_random_saturation Adjust the saturation of RGB images by a random factor deterministically. 
tf.image.stateless_random_saturation(
    image, lower, upper, seed=None
)
 Equivalent to adjust_saturation() but uses a saturation_factor randomly picked in the interval [lower, upper). Guarantees the same results given the same seed independent of how many times the function is called, and independent of global seed settings (e.g. tf.random.set_seed). 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]]]
seed = (1, 2)
tf.image.stateless_random_saturation(x, 0.5, 1.0, seed)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 1.1559395,  2.0779698,  3.       ],
        [ 4.1559396,  5.07797  ,  6.       ]],
       [[ 7.1559396,  8.07797  ,  9.       ],
        [10.155939 , 11.07797  , 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   A shape [2] Tensor, the seed to the random number generator. Must have dtype int32 or int64. (When using XLA, only int32 is allowed.)   
 


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

 


 Raises
  ValueError   if upper <= lower or if lower < 0.
tf.image.total_variation     View source on GitHub    Calculate and return the total variation for one or more images.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.total_variation  
tf.image.total_variation(
    images, name=None
)
 The total variation is the sum of the absolute differences for neighboring pixel-values in the input images. This measures how much noise is in the images. This can be used as a loss-function during optimization so as to suppress noise in images. If you have a batch of images, then you should calculate the scalar loss-value as the sum: loss = tf.reduce_sum(tf.image.total_variation(images)) This implements the anisotropic 2-D version of the formula described here: https://en.wikipedia.org/wiki/Total_variation_denoising
 


 Args
  images   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  name   A name for the operation (optional).   
 


 Raises
  ValueError   if images.shape is not a 3-D or 4-D vector.   
 


 Returns   The total variation of images. If images was 4-D, return a 1-D float Tensor of shape [batch] with the total variation for each image in the batch. If images was 3-D, return a scalar float with the total variation for that image.
tf.image.transpose     View source on GitHub    Transpose image(s) by swapping the height and width dimension.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.transpose, tf.compat.v1.image.transpose_image  
tf.image.transpose(
    image, name=None
)
 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.transpose(x)
<tf.Tensor: shape=(2, 2, 3), dtype=float32, numpy=
array([[[ 1.,  2.,  3.],
        [ 7.,  8.,  9.]],
       [[ 4.,  5.,  6.],
        [10., 11., 12.]]], dtype=float32)>

 


 Args
  image   4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor of shape [height, width, channels].  
  name   A name for this operation (optional).   
 


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

 


 Raises
  ValueError   if the shape of image not supported.    Usage Example: 
image = [[[1, 2], [3, 4]],
        [[5, 6], [7, 8]],
        [[9, 10], [11, 12]]]
image = tf.constant(image)
tf.image.transpose(image)
<tf.Tensor: shape=(2, 3, 2), dtype=int32, numpy=
array([[[ 1,  2],
       [ 5,  6],
       [ 9, 10]],
      [[ 3,  4],
       [ 7,  8],
       [11, 12]]], dtype=int32)>
tf.image.yiq_to_rgb     View source on GitHub    Converts one or more images from YIQ to RGB.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.yiq_to_rgb  
tf.image.yiq_to_rgb(
    images
)
 Outputs a tensor of the same shape as the images tensor, containing the RGB value of the pixels. The output is only well defined if the Y value in images are in [0,1], I value are in [-0.5957,0.5957] and Q value are in [-0.5226,0.5226].
 


 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.
tf.image.yuv_to_rgb     View source on GitHub    Converts one or more images from YUV to RGB.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.image.yuv_to_rgb  
tf.image.yuv_to_rgb(
    images
)
 Outputs a tensor of the same shape as the images tensor, containing the RGB value of the pixels. The output is only well defined if the Y value in images are in [0,1], U and V value are in [-0.5,0.5]. As per the above description, you need to scale your YUV images if their pixel values are not in the required range. Below given example illustrates preprocessing of each channel of images before feeding them to yuv_to_rgb. yuv_images = tf.random.uniform(shape=[100, 64, 64, 3], maxval=255)
last_dimension_axis = len(yuv_images.shape) - 1
yuv_tensor_images = tf.truediv(
    tf.subtract(
        yuv_images,
        tf.reduce_min(yuv_images)
    ),
    tf.subtract(
        tf.reduce_max(yuv_images),
        tf.reduce_min(yuv_images)
     )
)
y, u, v = tf.split(yuv_tensor_images, 3, axis=last_dimension_axis)
target_uv_min, target_uv_max = -0.5, 0.5
u = u * (target_uv_max - target_uv_min) + target_uv_min
v = v * (target_uv_max - target_uv_min) + target_uv_min
preprocessed_yuv_images = tf.concat([y, u, v], axis=last_dimension_axis)
rgb_tensor_images = tf.image.yuv_to_rgb(preprocessed_yuv_images)

 


 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.
tf.IndexedSlices     View source on GitHub    A sparse representation of a set of tensor slices at given indices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.IndexedSlices  
tf.IndexedSlices(
    values, indices, dense_shape=None
)
 This class is a simple wrapper for a pair of Tensor objects:  
values: A Tensor of any dtype with shape [D0, D1, ..., Dn]. 
indices: A 1-D integer Tensor with shape [D0].  An IndexedSlices is typically used to represent a subset of a larger tensor dense of shape [LARGE0, D1, .. , DN] where LARGE0 >> D0. The values in indices are the indices in the first dimension of the slices that have been extracted from the larger tensor. The dense tensor dense represented by an IndexedSlices slices has dense[slices.indices[i], :, :, :, ...] = slices.values[i, :, :, :, ...]
 The IndexedSlices class is used principally in the definition of gradients for operations that have sparse gradients (e.g. tf.gather). Contrast this representation with tf.sparse.SparseTensor, which uses multi-dimensional indices and scalar values.
 


 Attributes
  dense_shape   A 1-D Tensor containing the shape of the corresponding dense tensor.  
  device   The name of the device on which values will be produced, or None.  
  dtype   The DType of elements in this tensor.  
  graph   The Graph that contains the values, indices, and shape tensors.  
  indices   A 1-D Tensor containing the indices of the slices.  
  name   The name of this IndexedSlices.  
  op   The Operation that produces values as an output.  
  shape   Gets the tf.TensorShape representing the shape of the dense tensor.  
  values   A Tensor containing the values of the slices.    Methods consumers View source 
consumers()
 __neg__ View source 
__neg__()
tf.IndexedSlicesSpec     View source on GitHub    Type specification for a tf.IndexedSlices. Inherits From: TypeSpec  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.IndexedSlicesSpec  
tf.IndexedSlicesSpec(
    shape=None, dtype=tf.dtypes.float32, indices_dtype=tf.dtypes.int64,
    dense_shape_dtype=None, indices_shape=None
)

 


 Args
  shape   The dense shape of the IndexedSlices, or None to allow any dense shape.  
  dtype   tf.DType of values in the IndexedSlices.  
  indices_dtype   tf.DType of the indices in the IndexedSlices. One of tf.int32 or tf.int64.  
  dense_shape_dtype   tf.DType of the dense_shape in the IndexedSlices. One of tf.int32, tf.int64, or None (if the IndexedSlices has no dense_shape tensor).  
  indices_shape   The shape of the indices component, which indicates how many slices are in the IndexedSlices.   
 


 Attributes
  value_type  
   Methods is_compatible_with View source 
is_compatible_with(
    spec_or_value
)
 Returns true if spec_or_value is compatible with this TypeSpec. most_specific_compatible_type View source 
most_specific_compatible_type(
    other
)
 Returns the most specific TypeSpec compatible with self and other.
 


 Args
  other   A TypeSpec.   
 


 Raises
  ValueError   If there is no TypeSpec that is compatible with both self and other.    __eq__ View source 
__eq__(
    other
)
 Return self==value. __ne__ View source 
__ne__(
    other
)
 Return self!=value.