tensorflow/models

View on GitHub
research/object_detection/meta_architectures/deepmac_meta_arch.py

Summary

Maintainability
F
6 days
Test Coverage

File deepmac_meta_arch.py has 1629 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Deep Mask heads above CenterNet (DeepMAC)[1] architecture.

[1]: https://arxiv.org/abs/2104.00613
"""

Severity: Major
Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 4 days to fix

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

    def _get_deepmac_network_by_type(name, num_init_channels, mask_size=None):
      """Get DeepMAC network model given a string type."""
    
      if name.startswith('hourglass'):
        if name == 'hourglass10':
    Severity: Minor
    Found in research/object_detection/meta_architectures/deepmac_meta_arch.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(self,
    Severity: Major
    Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 1 hr to fix

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

        def _compute_deepmac_losses(
      Severity: Major
      Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 1 hr to fix

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

        def transform_images_and_boxes(images, boxes, tx, ty, sx, sy, flip):
        Severity: Major
        Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 50 mins to fix

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

          def transform_instance_masks(instance_masks, tx, ty, sx, sy, flip):
          Severity: Minor
          Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 45 mins to fix

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

              def _self_supervision_loss(
            Severity: Minor
            Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                def predict_masks_from_boxes(self, prediction_dict, true_image_shapes,
              Severity: Minor
              Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                  def _aggregate_classification_loss(self, loss, gt, pred, method):
                Severity: Minor
                Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                    def _transform_boxes_to_feature_coordinates(self, provided_boxes,
                  Severity: Minor
                  Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                      def __init__(self, network_type, num_init_channels=64,
                    Severity: Minor
                    Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                        def _compute_mask_prediction_loss(
                      Severity: Minor
                      Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

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

                        def subsample_instances(classes, weights, boxes, masks, num_subsamples):
                        Severity: Minor
                        Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 35 mins to fix

                          Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def __init__(self, resnet_type, num_init_channels):
                              """Creates the ResNet mask network.
                          
                              Args:
                                resnet_type: A string of the for resnetN where N where N is in
                          Severity: Minor
                          Found in research/object_detection/meta_architectures/deepmac_meta_arch.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 ResNetMaskNetwork(name, num_init_channels)
                          Severity: Major
                          Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return hourglass_network.hourglass_20_no_shortcut(num_init_channels)
                            Severity: Major
                            Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return tf.keras.layers.Lambda(lambda x: x)
                              Severity: Major
                              Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return config.pointly_supervised_keypoint_loss_weight
                                Severity: Major
                                Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return hourglass_network.hourglass_20_uniform_size(num_init_channels)
                                  Severity: Major
                                  Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                          return hourglass_network.hourglass_100(num_init_channels,
                                    Severity: Major
                                    Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                          return FullyConnectedMaskHead(num_init_channels, mask_size)
                                      Severity: Major
                                      Found in research/object_detection/meta_architectures/deepmac_meta_arch.py - About 30 mins to fix

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

                                        def _get_loss_weight(loss_name, config):
                                          """Utility function to get loss weights by name."""
                                          if loss_name == DEEP_MASK_ESTIMATION:
                                            return config.task_loss_weight
                                          elif loss_name == DEEP_MASK_FEATURE_CONSISTENCY:
                                        Severity: Minor
                                        Found in research/object_detection/meta_architectures/deepmac_meta_arch.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