Example #1
0
  with ops.op_scope([images, contrast_factor], None, 'adjust_contrast') as name:
    # Remember original dtype to so we can convert back if needed
    orig_dtype = images.dtype
    flt_images = convert_image_dtype(images, dtypes.float32)

    # pylint: disable=protected-access
    adjusted = gen_image_ops._adjust_contrastv2(flt_images,
                                                contrast_factor=contrast_factor,
                                                name=name)
    # pylint: enable=protected-access

    return convert_image_dtype(adjusted, orig_dtype, saturate=True)


ops.RegisterShape('AdjustContrast')(
    common_shapes.unchanged_shape_with_rank_at_least(3))
ops.RegisterShape('AdjustContrastv2')(
    common_shapes.unchanged_shape_with_rank_at_least(3))


@ops.RegisterShape('ResizeBilinear')
@ops.RegisterShape('ResizeNearestNeighbor')
@ops.RegisterShape('ResizeBicubic')
@ops.RegisterShape('ResizeArea')
def _ResizeShape(op):
  """Shape function for the resize_bilinear and resize_nearest_neighbor ops."""
  input_shape = op.inputs[0].get_shape().with_rank(4)
  size = tensor_util.ConstantValue(op.inputs[1])
  if size is not None:
    height = size[0]
    width = size[1]
Example #2
0
    with ops.op_scope([images, contrast_factor], None,
                      'adjust_contrast') as name:
        # Remember original dtype to so we can convert back if needed
        orig_dtype = images.dtype
        flt_images = convert_image_dtype(images, dtypes.float32)

        # pylint: disable=protected-access
        adjusted = gen_image_ops._adjust_contrastv2(
            flt_images, contrast_factor=contrast_factor, name=name)
        # pylint: enable=protected-access

        return convert_image_dtype(adjusted, orig_dtype, saturate=True)


ops.RegisterShape('AdjustContrast')(
    common_shapes.unchanged_shape_with_rank_at_least(3))
ops.RegisterShape('AdjustContrastv2')(
    common_shapes.unchanged_shape_with_rank_at_least(3))


@ops.RegisterShape('ResizeBilinear')
@ops.RegisterShape('ResizeNearestNeighbor')
@ops.RegisterShape('ResizeBicubic')
@ops.RegisterShape('ResizeArea')
def _ResizeShape(op):
    """Shape function for the resize_bilinear and resize_nearest_neighbor ops."""
    input_shape = op.inputs[0].get_shape().with_rank(4)
    size = tensor_util.constant_value(op.inputs[1])
    if size is not None:
        height = size[0]
        width = size[1]
Example #3
0
  Returns:
    The constrast-adjusted image or images.
  """
    with ops.op_scope([images, contrast_factor], None, "adjust_contrast") as name:
        # Remember original dtype to so we can convert back if needed
        orig_dtype = images.dtype
        flt_images = convert_image_dtype(images, dtypes.float32)

        # pylint: disable=protected-access
        adjusted = gen_image_ops._adjust_contrastv2(flt_images, contrast_factor=contrast_factor, name=name)
        # pylint: enable=protected-access

        return convert_image_dtype(adjusted, orig_dtype, saturate=True)


ops.RegisterShape("AdjustContrast")(common_shapes.unchanged_shape_with_rank_at_least(3))
ops.RegisterShape("AdjustContrastv2")(common_shapes.unchanged_shape_with_rank_at_least(3))


@ops.RegisterShape("ResizeBilinear")
@ops.RegisterShape("ResizeNearestNeighbor")
@ops.RegisterShape("ResizeBicubic")
@ops.RegisterShape("ResizeArea")
def _ResizeShape(op):
    """Shape function for the resize_bilinear and resize_nearest_neighbor ops."""
    input_shape = op.inputs[0].get_shape().with_rank(4)
    unused_size_shape = op.inputs[1].get_shape().merge_with([2])
    size = tensor_util.constant_value(op.inputs[1])
    if size is not None:
        height = size[0]
        width = size[1]