tensorflow/tensorflow

View on GitHub
tensorflow/python/ops/image_ops_impl.py

Summary

Maintainability
F
2 wks
Test Coverage

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
Severity: Major
Found in tensorflow/python/ops/image_ops_impl.py - About 1 wk to fix

    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
    Severity: Minor
    Found in tensorflow/python/ops/image_ops_impl.py - About 4 hrs to fix

    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`,
    Severity: Minor
    Found in tensorflow/python/ops/image_ops_impl.py - About 3 hrs to fix

    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.
    Severity: Minor
    Found in tensorflow/python/ops/image_ops_impl.py - About 2 hrs to fix

    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,
    Severity: Minor
    Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

    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')
    Severity: Minor
    Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

    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,
    Severity: Major
    Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

      Function non_max_suppression_padded has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def non_max_suppression_padded(boxes,
      Severity: Major
      Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

        Function stateless_sample_distorted_bounding_box has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def stateless_sample_distorted_bounding_box(image_size,
        Severity: Major
        Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

          Function sample_distorted_bounding_box_v2 has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def sample_distorted_bounding_box_v2(image_size,
          Severity: Major
          Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

            Function combined_non_max_suppression has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def combined_non_max_suppression(boxes,
            Severity: Major
            Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

              Function generate_bounding_box_proposals has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def generate_bounding_box_proposals(scores,
              Severity: Major
              Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                Function crop_and_resize_v1 has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def crop_and_resize_v1(  # pylint: disable=missing-docstring
                Severity: Major
                Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                  Function ssim has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def ssim(img1,
                  Severity: Major
                  Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                    Function ssim_multiscale has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def ssim_multiscale(img1,
                    Severity: Major
                    Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                      Function _ssim_per_channel has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def _ssim_per_channel(img1,
                      Severity: Major
                      Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                        Function extract_glimpse_v2 has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def extract_glimpse_v2(
                        Severity: Major
                        Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                          Function extract_glimpse has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def extract_glimpse(
                          Severity: Major
                          Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                            Function non_max_suppression_padded_v2 has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def non_max_suppression_padded_v2(boxes,
                            Severity: Major
                            Found in tensorflow/python/ops/image_ops_impl.py - About 1 hr to fix

                              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]
                              Severity: Minor
                              Found in tensorflow/python/ops/image_ops_impl.py - About 55 mins to fix

                              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')
                              Severity: Minor
                              Found in tensorflow/python/ops/image_ops_impl.py - About 55 mins to fix

                              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,
                              Severity: Major
                              Found in tensorflow/python/ops/image_ops_impl.py - About 50 mins to fix

                                Function crop_and_resize_v2 has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def crop_and_resize_v2(image,
                                Severity: Major
                                Found in tensorflow/python/ops/image_ops_impl.py - About 50 mins to fix

                                  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):
                                  Severity: Major
                                  Found in tensorflow/python/ops/image_ops_impl.py - About 50 mins to fix

                                    Function non_max_suppression_padded_v1 has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    def non_max_suppression_padded_v1(boxes,
                                    Severity: Major
                                    Found in tensorflow/python/ops/image_ops_impl.py - About 50 mins to fix

                                      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,
                                      Severity: Minor
                                      Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                        Function resize_images has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                        def resize_images(images,
                                        Severity: Minor
                                        Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                          Function resize_images_v2 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                          def resize_images_v2(images,
                                          Severity: Minor
                                          Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                            Function non_max_suppression_with_overlaps has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                            def non_max_suppression_with_overlaps(overlaps,
                                            Severity: Minor
                                            Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                              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,
                                              Severity: Minor
                                              Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                                Function non_max_suppression has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                def non_max_suppression(boxes,
                                                Severity: Minor
                                                Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                                  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,
                                                  Severity: Minor
                                                  Found in tensorflow/python/ops/image_ops_impl.py - About 45 mins to fix

                                                  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,
                                                  Severity: Minor
                                                  Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                    Function resize_bilinear has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                    def resize_bilinear(images,
                                                    Severity: Minor
                                                    Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                      Function resize_image_with_pad_v1 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                      def resize_image_with_pad_v1(image,
                                                      Severity: Minor
                                                      Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                        Function resize_image_with_pad_v2 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                        def resize_image_with_pad_v2(image,
                                                        Severity: Minor
                                                        Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                          Function decode_image has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                          def decode_image(contents,
                                                          Severity: Minor
                                                          Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                            Function resize_nearest_neighbor has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                            def resize_nearest_neighbor(images,
                                                            Severity: Minor
                                                            Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                              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,
                                                              Severity: Minor
                                                              Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                                Function resize_bicubic has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                Open

                                                                def resize_bicubic(images,
                                                                Severity: Minor
                                                                Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                                  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):
                                                                  Severity: Minor
                                                                  Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                                    Function _cross_suppression has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                    Open

                                                                    def _cross_suppression(boxes, box_slice, iou_threshold, inner_idx, tile_size):
                                                                    Severity: Minor
                                                                    Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                                      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]
                                                                      Severity: Minor
                                                                      Found in tensorflow/python/ops/image_ops_impl.py - About 35 mins to fix

                                                                      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)
                                                                      Severity: Major
                                                                      Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                              return resize_with_scale_and_translate(method)
                                                                        Severity: Major
                                                                        Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                return math_ops.cast(image, dtype, name=name)
                                                                          Severity: Major
                                                                          Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                    return math_ops.multiply(cast, scale, name=name)
                                                                            Severity: Major
                                                                            Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                        return math_ops.saturate_cast(scaled, dtype, name=name)
                                                                              Severity: Major
                                                                              Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                          return math_ops.cast(scaled, dtype, name=name)
                                                                                Severity: Major
                                                                                Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                          return gen_image_ops.resize_bicubic(
                                                                                  Severity: Major
                                                                                  Found in tensorflow/python/ops/image_ops_impl.py - About 30 mins to fix

                                                                                    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
                                                                                    Severity: Minor
                                                                                    Found in tensorflow/python/ops/image_ops_impl.py - About 25 mins to fix

                                                                                    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
                                                                                    Severity: Minor
                                                                                    Found in tensorflow/python/ops/image_ops_impl.py - About 25 mins to fix

                                                                                    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]
                                                                                    Severity: Minor
                                                                                    Found in tensorflow/python/ops/image_ops_impl.py - About 25 mins to fix

                                                                                    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

                                                                                    There are no issues that match your filters.

                                                                                    Category
                                                                                    Status