tensorflow/models

View on GitHub
official/vision/utils/object_detection/visualization_utils.py

Summary

Maintainability
F
6 days
Test Coverage

File visualization_utils.py has 910 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2024 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 official/vision/utils/object_detection/visualization_utils.py - About 2 days to fix

    Function visualize_boxes_and_labels_on_image_array has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

    def visualize_boxes_and_labels_on_image_array(
        image,
        boxes,
        classes,
        scores,
    Severity: Minor
    Found in official/vision/utils/object_detection/visualization_utils.py - About 1 day 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 visualize_segmentation_outputs has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def visualize_segmentation_outputs(
        logs,
        task_config,
        original_image_spatial_shape=None,
        true_image_shape=None,
    Severity: Minor
    Found in official/vision/utils/object_detection/visualization_utils.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 visualize_boxes_and_labels_on_image_array has 16 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def visualize_boxes_and_labels_on_image_array(
    Severity: Major
    Found in official/vision/utils/object_detection/visualization_utils.py - About 2 hrs to fix

      Function visualize_outputs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def visualize_outputs(
          logs,
          task_config,
          original_image_spatial_shape=None,
          true_image_shape=None,
      Severity: Minor
      Found in official/vision/utils/object_detection/visualization_utils.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 draw_bounding_boxes_on_image_tensors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def draw_bounding_boxes_on_image_tensors(images,
                                               boxes,
                                               classes,
                                               scores,
                                               category_index,
      Severity: Minor
      Found in official/vision/utils/object_detection/visualization_utils.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 draw_bounding_box_on_image has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def draw_bounding_box_on_image(image,
                                     ymin,
                                     xmin,
                                     ymax,
                                     xmax,
      Severity: Minor
      Found in official/vision/utils/object_detection/visualization_utils.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 draw_bounding_boxes_on_image_tensors has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def draw_bounding_boxes_on_image_tensors(images,
      Severity: Major
      Found in official/vision/utils/object_detection/visualization_utils.py - About 1 hr to fix

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

        def visualize_outputs(
        Severity: Major
        Found in official/vision/utils/object_detection/visualization_utils.py - About 1 hr to fix

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

          def draw_bounding_box_on_image_array(image,
          Severity: Major
          Found in official/vision/utils/object_detection/visualization_utils.py - About 1 hr to fix

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

            def draw_bounding_box_on_image(image,
            Severity: Major
            Found in official/vision/utils/object_detection/visualization_utils.py - About 1 hr to fix

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

              def _visualize_boxes_and_masks_and_keypoints(image, boxes, classes, scores,
              Severity: Major
              Found in official/vision/utils/object_detection/visualization_utils.py - About 1 hr to fix

                Function update_detection_state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                def update_detection_state(step_outputs=None) -> Dict[str, Any]:
                  """Updates detection state to optionally add input image and predictions."""
                  state = {}
                  if step_outputs:
                    state['image'] = tf.concat(step_outputs['visualization'][0], axis=0)
                Severity: Minor
                Found in official/vision/utils/object_detection/visualization_utils.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 visualize_segmentation_outputs has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def visualize_segmentation_outputs(
                Severity: Major
                Found in official/vision/utils/object_detection/visualization_utils.py - About 50 mins to fix

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

                  def _visualize_boxes_and_keypoints(image, boxes, classes, scores, keypoints,
                  Severity: Major
                  Found in official/vision/utils/object_detection/visualization_utils.py - About 50 mins to fix

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

                    def _visualize_boxes_and_masks(image, boxes, classes, scores, masks,
                    Severity: Major
                    Found in official/vision/utils/object_detection/visualization_utils.py - About 50 mins to fix

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

                      def _visualize_boxes(image, boxes, classes, scores, category_index, **kwargs):
                      Severity: Minor
                      Found in official/vision/utils/object_detection/visualization_utils.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if not agnostic_mode:
                                    if classes[i] in category_index.keys():
                                      class_name = category_index[classes[i]]['name']
                                    else:
                                      class_name = 'N/A'
                        Severity: Major
                        Found in official/vision/utils/object_detection/visualization_utils.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if not display_str:
                                      display_str = '{}%'.format(int(100 * scores[i]))
                                    else:
                                      display_str = '{}: {}%'.format(display_str, int(100 * scores[i]))
                                  box_to_display_str_map[box].append(display_str)
                          Severity: Major
                          Found in official/vision/utils/object_detection/visualization_utils.py - About 45 mins to fix

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

                            def draw_bounding_boxes_on_image_array(image,
                            Severity: Minor
                            Found in official/vision/utils/object_detection/visualization_utils.py - About 35 mins to fix

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

                              def draw_bounding_boxes_on_image(image,
                              Severity: Minor
                              Found in official/vision/utils/object_detection/visualization_utils.py - About 35 mins to fix

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

                                def draw_keypoints_on_image(image,
                                Severity: Minor
                                Found in official/vision/utils/object_detection/visualization_utils.py - About 35 mins to fix

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

                                  def draw_keypoints_on_image_array(image,
                                  Severity: Minor
                                  Found in official/vision/utils/object_detection/visualization_utils.py - About 35 mins to fix

                                    Function draw_bounding_boxes_on_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    def draw_bounding_boxes_on_image(image,
                                                                     boxes,
                                                                     color='red',
                                                                     thickness=4,
                                                                     display_str_list_list=()):
                                    Severity: Minor
                                    Found in official/vision/utils/object_detection/visualization_utils.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