tensorflow/models

View on GitHub
research/object_detection/metrics/lvis_tools.py

Summary

Maintainability
D
2 days
Test Coverage

Function ExportSingleImageGroundtruthToLVIS has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def ExportSingleImageGroundtruthToLVIS(image_id,
                                       next_annotation_id,
                                       category_id_set,
                                       groundtruth_boxes,
                                       groundtruth_classes,
Severity: Minor
Found in research/object_detection/metrics/lvis_tools.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 ExportSingleImageGroundtruthToLVIS has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def ExportSingleImageGroundtruthToLVIS(image_id,
Severity: Major
Found in research/object_detection/metrics/lvis_tools.py - About 50 mins to fix

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

    def ExportSingleImageDetectionMasksToLVIS(image_id,
    Severity: Minor
    Found in research/object_detection/metrics/lvis_tools.py - About 35 mins to fix

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

      def ExportSingleImageDetectionMasksToLVIS(image_id,
                                                category_id_set,
                                                detection_masks,
                                                detection_scores,
                                                detection_classes):
      Severity: Minor
      Found in research/object_detection/metrics/lvis_tools.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

            if groundtruth_area is not None and groundtruth_area[i] > 0:
              area = float(groundtruth_area[i])
            else:
              area = float((groundtruth_boxes[i, 2] - groundtruth_boxes[i, 0]) *
                           (groundtruth_boxes[i, 3] - groundtruth_boxes[i, 1]))
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 1 other location - About 6 hrs to fix
      research/object_detection/metrics/coco_tools.py on lines 474..478

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 106.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      def _ConvertBoxToCOCOFormat(box):
        """Converts a box in [ymin, xmin, ymax, xmax] format to COCO format.
      
        This is a utility function for converting from our internal
        [ymin, xmin, ymax, xmax] convention to the convention used by the COCO API
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 1 other location - About 4 hrs to fix
      research/object_detection/metrics/coco_tools.py on lines 359..373

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 81.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        if not num_boxes == len(detection_masks) == detection_scores.shape[0]:
          raise ValueError('Corresponding entries in detection_classes, '
                           'detection_scores and detection_masks should have '
                           'compatible lengths and shapes '
                           'Classes length: %d.  Masks length: %d. '
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 1 other location - About 3 hrs to fix
      research/object_detection/metrics/coco_tools.py on lines 719..726

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 65.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      def RleCompress(masks):
        """Compresses mask using Run-length encoding provided by pycocotools.
      
        Args:
          masks: uint8 numpy array of shape [mask_height, mask_width] with values in
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 1 other location - About 2 hrs to fix
      research/object_detection/metrics/coco_tools.py on lines 376..388

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 52.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        if num_boxes != groundtruth_boxes.shape[0]:
          raise ValueError('Corresponding entries in groundtruth_classes, '
                           'and groundtruth_boxes should have '
                           'compatible shapes (i.e., agree on the 0th dimension).'
                           'Classes shape: %d. Boxes shape: %d. Image ID: %s' % (
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 1 other location - About 2 hrs to fix
      research/object_detection/metrics/coco_tools.py on lines 455..461

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 51.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

        if len(detection_classes.shape) != 1 or len(detection_scores.shape) != 1:
          raise ValueError('All entries in detection_classes and detection_scores'
      Severity: Major
      Found in research/object_detection/metrics/lvis_tools.py and 4 other locations - About 1 hr to fix
      research/object_detection/metrics/coco_tools.py on lines 630..631
      research/object_detection/metrics/coco_tools.py on lines 715..716
      research/object_detection/metrics/coco_tools.py on lines 861..862
      research/object_detection/metrics/coco_tools.py on lines 938..939

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 40.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status