File image_ops_impl.py
has 4819 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Function central_crop
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def central_crop(image, central_fraction):
"""Crop the central region of the image(s).
Remove the outer parts of an image but retain the central region of the image
along each dimension. If we specify `central_fraction = 0.5`, this function
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convert_image_dtype
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def convert_image_dtype(image, dtype, saturate=False, name=None):
"""Convert `image` to `dtype`, scaling its values if needed.
The operation supports data types (for `image` and `dtype`) of
`uint8`, `uint16`, `uint32`, `uint64`, `int8`, `int16`, `int32`, `int64`,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resize_image_with_crop_or_pad
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def resize_image_with_crop_or_pad(image, target_height, target_width):
"""Crops and/or pads an image to a target width and height.
Resizes an image to a target width and height by either centrally
cropping the image or padding it evenly with zeros.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resize_images_v2
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def resize_images_v2(images,
size,
method=ResizeMethod.BILINEAR,
preserve_aspect_ratio=False,
antialias=False,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _resize_images_common
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _resize_images_common(images, resizer_fn, size, preserve_aspect_ratio, name,
skip_resize_if_same):
"""Core functionality for v1 and v2 resize functions."""
with ops.name_scope(name, 'resize', [images, size]):
images = ops.convert_to_tensor(images, name='images')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function sample_distorted_bounding_box
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def sample_distorted_bounding_box(image_size,
Function non_max_suppression_padded
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression_padded(boxes,
Function stateless_sample_distorted_bounding_box
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def stateless_sample_distorted_bounding_box(image_size,
Function sample_distorted_bounding_box_v2
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def sample_distorted_bounding_box_v2(image_size,
Function combined_non_max_suppression
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def combined_non_max_suppression(boxes,
Function generate_bounding_box_proposals
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def generate_bounding_box_proposals(scores,
Function crop_and_resize_v1
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def crop_and_resize_v1( # pylint: disable=missing-docstring
Function ssim
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def ssim(img1,
Function ssim_multiscale
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def ssim_multiscale(img1,
Function _ssim_per_channel
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def _ssim_per_channel(img1,
Function extract_glimpse_v2
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def extract_glimpse_v2(
Function extract_glimpse
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def extract_glimpse(
Function non_max_suppression_padded_v2
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression_padded_v2(boxes,
Function _CheckGrayscaleImage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _CheckGrayscaleImage(image, require_static=True):
"""Assert that we are working with properly shaped grayscale image.
Args:
image: >= 2-D Tensor of size [*, 1]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _resize_image_with_pad_common
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _resize_image_with_pad_common(image, target_height, target_width,
resize_fn):
"""Core functionality for v1 and v2 resize_image_with_pad functions."""
with ops.name_scope(None, 'resize_image_with_pad', [image]):
image = ops.convert_to_tensor(image, name='image')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function non_max_suppression_with_scores
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression_with_scores(boxes,
Function crop_and_resize_v2
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def crop_and_resize_v2(image,
Function _ssim_helper
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _ssim_helper(x, y, reducer, max_val, compensation=1.0, k1=0.01, k2=0.03):
Function non_max_suppression_padded_v1
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression_padded_v1(boxes,
Function _resize_images_common
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _resize_images_common(images, resizer_fn, size, preserve_aspect_ratio, name,
Function resize_images
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_images(images,
Function resize_images_v2
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_images_v2(images,
Function non_max_suppression_with_overlaps
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression_with_overlaps(overlaps,
Function pad_to_bounding_box_internal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def pad_to_bounding_box_internal(image, offset_height, offset_width,
Function non_max_suppression
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def non_max_suppression(boxes,
Function resize_images
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def resize_images(images,
size,
method=ResizeMethodV1.BILINEAR,
align_corners=False,
preserve_aspect_ratio=False,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function crop_to_bounding_box
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def crop_to_bounding_box(image, offset_height, offset_width, target_height,
Function resize_bilinear
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_bilinear(images,
Function resize_image_with_pad_v1
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_image_with_pad_v1(image,
Function resize_image_with_pad_v2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_image_with_pad_v2(image,
Function decode_image
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def decode_image(contents,
Function resize_nearest_neighbor
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_nearest_neighbor(images,
Function pad_to_bounding_box
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def pad_to_bounding_box(image, offset_height, offset_width, target_height,
Function resize_bicubic
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def resize_bicubic(images,
Function _suppression_loop_body
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _suppression_loop_body(boxes, iou_threshold, output_size, idx, tile_size):
Function _cross_suppression
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _cross_suppression(boxes, box_slice, iou_threshold, inner_idx, tile_size):
Function _CheckAtLeast3DImage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _CheckAtLeast3DImage(image, require_static=True):
"""Assert that we are working with a properly shaped image.
Args:
image: >= 3-D Tensor of size [*, height, width, depth]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return gen_image_ops.resize_area(images_t, new_size)
Avoid too many return
statements within this function. Open
return resize_with_scale_and_translate(method)
Avoid too many return
statements within this function. Open
return math_ops.cast(image, dtype, name=name)
Avoid too many return
statements within this function. Open
return math_ops.multiply(cast, scale, name=name)
Avoid too many return
statements within this function. Open
return math_ops.saturate_cast(scaled, dtype, name=name)
Avoid too many return
statements within this function. Open
return math_ops.cast(scaled, dtype, name=name)
Avoid too many return
statements within this function. Open
return gen_image_ops.resize_bicubic(
Function adjust_hue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def adjust_hue(image, delta, name=None):
"""Adjust hue of RGB images.
This is a convenience method that converts an RGB image to float
representation, converts it to HSV, adds an offset to the
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function pad_to_bounding_box_internal
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def pad_to_bounding_box_internal(image, offset_height, offset_width,
target_height, target_width, check_dims):
"""Pad `image` with zeros to the specified `height` and `width`.
Adds `offset_height` rows of zeros on top, `offset_width` columns of
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _Check3DImage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _Check3DImage(image, require_static=True):
"""Assert that we are working with a properly shaped image.
Args:
image: 3-D Tensor of shape [height, width, channels]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"