tensorflow/models

View on GitHub
research/object_detection/utils/np_box_list_ops.py

Summary

Maintainability
F
4 days
Test Coverage

File np_box_list_ops.py has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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: Minor
Found in research/object_detection/utils/np_box_list_ops.py - About 6 hrs to fix

    Function non_max_suppression has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def non_max_suppression(boxlist,
                            max_output_size=10000,
                            iou_threshold=1.0,
                            score_threshold=-10.0):
      """Non maximum suppression.
    Severity: Minor
    Found in research/object_detection/utils/np_box_list_ops.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 concatenate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def concatenate(boxlists, fields=None):
      """Concatenate list of BoxLists.
    
      This op concatenates a list of input BoxLists into a larger BoxList.  It also
      handles concatenation of BoxList fields as long as the field tensor shapes
    Severity: Minor
    Found in research/object_detection/utils/np_box_list_ops.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 multi_class_non_max_suppression has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def multi_class_non_max_suppression(boxlist, score_thresh, iou_thresh,
                                        max_output_size):
      """Multi-class version of non maximum suppression.
    
      This op greedily selects a subset of detection bounding boxes, pruning
    Severity: Minor
    Found in research/object_detection/utils/np_box_list_ops.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 gather has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def gather(boxlist, indices, fields=None):
      """Gather boxes from BoxList according to indices and return new BoxList.
    
      By default, gather returns boxes corresponding to the input index list, as
      well as all additional fields stored in the boxlist (indexing into the
    Severity: Minor
    Found in research/object_detection/utils/np_box_list_ops.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

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

    def filter_scores_greater_than(boxlist, thresh):
      """Filter to keep only boxes with score exceeding a given threshold.
    
      This op keeps the collection of boxes whose corresponding scores are
      greater than the input threshold.
    Severity: Major
    Found in research/object_detection/utils/np_box_list_ops.py and 1 other location - About 1 day to fix
    research/object_detection/utils/np_box_mask_list_ops.py on lines 374..404

    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 172.

    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 prune_non_overlapping_boxes(boxlist1, boxlist2, minoverlap=0.0):
      """Prunes the boxes in boxlist1 that overlap less than thresh with boxlist2.
    
      For each box in boxlist1, we want its IOA to be more than minoverlap with
      at least one of the boxes in boxlist2. If it does not, we remove it.
    Severity: Major
    Found in research/object_detection/utils/np_box_list_ops.py and 1 other location - About 5 hrs to fix
    research/object_detection/utils/np_box_mask_list_ops.py on lines 321..342

    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 86.

    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 len(scores.shape) == 1:
        scores = np.reshape(scores, [-1, 1])
      elif len(scores.shape) == 2:
        if scores.shape[1] is None:
          raise ValueError('scores field must have statically defined second '
    Severity: Major
    Found in research/object_detection/utils/np_box_list_ops.py and 1 other location - About 4 hrs to fix
    research/object_detection/utils/np_box_mask_list_ops.py on lines 282..289

    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

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

      if iou_threshold == 1.0:
        if boxlist.num_boxes() > max_output_size:
          selected_indices = np.arange(max_output_size)
          return gather(boxlist, selected_indices)
        else:
    Severity: Major
    Found in research/object_detection/utils/np_box_list_ops.py and 1 other location - About 1 hr to fix
    research/object_detection/utils/np_box_mask_list_ops.py on lines 210..215

    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 47.

    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 5 locations. Consider refactoring.
    Open

    def _copy_extra_fields(boxlist_to_copy_to, boxlist_to_copy_from):
      """Copies the extra fields of boxlist_to_copy_from to boxlist_to_copy_to.
    
      Args:
        boxlist_to_copy_to: BoxList to which extra fields are copied.
    Severity: Major
    Found in research/object_detection/utils/np_box_list_ops.py and 4 other locations - About 1 hr to fix
    official/projects/centernet/ops/box_list_ops.py on lines 23..35
    official/vision/utils/object_detection/box_list_ops.py on lines 764..776
    official/vision/utils/object_detection/preprocessor.py on lines 428..440
    research/object_detection/core/box_list_ops.py on lines 829..841

    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 39.

    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