tensorflow/models

View on GitHub
official/projects/edgetpu/vision/modeling/heads/bifpn_head.py

Summary

Maintainability
F
3 days
Test Coverage

File bifpn_head.py has 616 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/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 1 day to fix

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

      def __init__(self,
    Severity: Major
    Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 2 hrs to fix

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

        def __init__(self,
      Severity: Major
      Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 2 hrs to fix

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

          def __init__(self,
        Severity: Major
        Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 2 hrs to fix

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

          def resize(feat,
                     target_height,
                     target_width,
                     strategy,
                     training=False,
          Severity: Minor
          Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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 15 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def __init__(self,
          Severity: Major
          Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 1 hr to fix

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

              def call(self, feat, training, all_feats):
                hwc_idx = (2, 3, 1) if self.data_format == 'channels_first' else (1, 2, 3)
                height, width, num_channels = [feat.shape.as_list()[i] for i in hwc_idx]
                if all_feats:
                  target_feat_shape = all_feats[self.feat_level].shape.as_list()
            Severity: Minor
            Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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 official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 1 hr to fix

              Function call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def call(self, feats, training):
                  """Model call function."""
                  for cell in self.cells:
                    cell_feats = cell(feats, training)
                    min_level = self.min_level
              Severity: Minor
              Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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 build_batch_norm has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def build_batch_norm(is_training_bn: bool,
              Severity: Major
              Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 1 hr to fix

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

                  def __init__(self,
                Severity: Major
                Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 1 hr to fix

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

                  def resize(feat,
                  Severity: Minor
                  Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 45 mins to fix

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

                      def _pool2d(self, inputs, height, width, target_height, target_width):
                    Severity: Minor
                    Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return tf.nn.relu6(features)
                      Severity: Major
                      Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.py - About 30 mins to fix

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

                          def fuse_features(self, nodes):
                            """Fuses features from different resolutions and return a weighted sum.
                        
                            Args:
                              nodes: a list of tensorflow features at different levels
                        Severity: Minor
                        Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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 activation_fn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def activation_fn(features: tf.Tensor, act_type: Text):
                          """Customized non-linear activation type."""
                          if act_type in ('silu', 'swish'):
                            return tf.nn.swish(features)
                          elif act_type == 'swish_native':
                        Severity: Minor
                        Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def call(self, inputs, backbone_feats, training):
                            """Call SegClassNet."""
                        
                            seg_output = self.fnode(inputs, training)
                            net = seg_output[-1]
                        Severity: Minor
                        Found in official/projects/edgetpu/vision/modeling/heads/bifpn_head.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