tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

Avoid deeply nested control flow statements.
Open

          if isinstance(groundtruths['masks'][i][j, k], tf.Tensor):
            mask = Image.open(
                six.BytesIO(groundtruths['masks'][i][j, k].numpy()))
          else:
            mask = Image.open(
Severity: Major
Found in official/vision/evaluation/coco_utils.py - About 45 mins to fix

    Function test_pad_groundtruths_to_fixed_size has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def test_pad_groundtruths_to_fixed_size(self, boxes, area, classes, size,
                                              attributes):
        groundtruths = {}
        groundtruths['boxes'] = tf.constant(boxes)
        groundtruths['is_crowds'] = tf.constant([[0]])
    Severity: Minor
    Found in official/vision/dataloaders/utils_test.py - About 45 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 validation_step has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def validation_step(self,
                          inputs: Tuple[Any, Any],
                          model: tf_keras.Model,
                          metrics: Optional[List[Any]] = None):
        """Validatation step.
    Severity: Minor
    Found in official/vision/tasks/semantic_segmentation.py - About 45 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 deeply nested control flow statements.
    Open

                for j, iou in enumerate(iou_thresholds):
                  if int(iou * 100) in {50, 75}:
                    logs[f'{prefix}{ap_key}{int(iou * 100)} ByCategory/{k}'] = (
                        per_class_ap[j][k]
                    )
    Severity: Major
    Found in official/vision/tasks/maskrcnn.py - About 45 mins to fix

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

        def test_forward(self, strategy, image_size, training, has_att_heads,
      Severity: Minor
      Found in official/vision/modeling/retinanet_model_test.py - About 45 mins to fix

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

          def testDetectionsOutputShape(
        Severity: Minor
        Found in official/vision/modeling/layers/detection_generator_test.py - About 45 mins to fix

          Function build_metrics has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def build_metrics(self, training: bool = True):
              """Gets streaming metrics for training/validation."""
              metrics = []
              self.iou_metric = None
          
          
          Severity: Minor
          Found in official/vision/tasks/semantic_segmentation.py - About 45 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 deeply nested control flow statements.
          Open

                      for class_id in range(self.task_config.model.num_classes):
                        metrics += [
                            tf_keras.metrics.Precision(
                                thresholds=th,
                                class_id=class_id,
          Severity: Major
          Found in official/vision/tasks/image_classification.py - About 45 mins to fix

            Function train_step has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def train_step(self,
                             inputs: Tuple[Any, Any],
                             model: tf_keras.Model,
                             optimizer: tf_keras.optimizers.Optimizer,
                             metrics: Optional[List[Any]] = None):
            Severity: Minor
            Found in official/vision/tasks/maskrcnn.py - About 45 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 _generate_detections_v2_class_agnostic has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def _generate_detections_v2_class_agnostic(
            Severity: Minor
            Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

              Function build has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def build(self, input_shape):
                  if self._use_projection:
                    if self._resnetd_shortcut:
                      self._shortcut0 = tf_keras.layers.AveragePooling2D(
                          pool_size=2, strides=self._strides, padding='same')
              Severity: Minor
              Found in official/vision/modeling/layers/nn_blocks.py - About 45 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 _maximum_activation_size has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def _maximum_activation_size(model):
                max_size = 0
                for layer in model.layers:
                  outputs = layer.output
                  if not isinstance(outputs, list):
              Severity: Minor
              Found in official/vision/modeling/layers/edgetpu_test.py - About 45 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(self, model: tf_keras.Model):
                  """Loads pretrained checkpoint."""
              
                  if not self.task_config.init_checkpoint:
                    return
              Severity: Minor
              Found in official/vision/tasks/maskrcnn.py - About 45 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 build_losses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def build_losses(self,
                                 labels: tf.Tensor,
                                 model_outputs: tf.Tensor,
                                 aux_losses: Optional[Any] = None) -> tf.Tensor:
                  """Builds sparse categorical cross entropy loss.
              Severity: Minor
              Found in official/vision/tasks/image_classification.py - About 45 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(self, model: tf_keras.Model):
                  """Loads pretrained checkpoint."""
                  if not self.task_config.init_checkpoint:
                    return
              
              
              Severity: Minor
              Found in official/vision/tasks/semantic_segmentation.py - About 45 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 deeply nested control flow statements.
              Open

                        if use_batched_nms:
                          this_level_rois, this_level_roi_scores, _, _ = (
                              tf.image.combined_non_max_suppression(
                                  tf.expand_dims(this_level_boxes, axis=2),
                                  tf.expand_dims(this_level_scores, axis=-1),
              Severity: Major
              Found in official/vision/modeling/layers/roi_generator.py - About 45 mins to fix

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

                  def __init__(
                Severity: Minor
                Found in official/vision/modeling/layers/nn_blocks.py - About 45 mins to fix

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

                    def __init__(
                  Severity: Minor
                  Found in official/vision/modeling/layers/nn_blocks.py - About 45 mins to fix

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

                    def _generate_detections_v2_class_aware(
                    Severity: Minor
                    Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

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

                      def to_absolute_coordinates(boxlist,
                      Severity: Minor
                      Found in official/vision/utils/object_detection/box_list_ops.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language