tensorflow/models

View on GitHub
official/vision/dataloaders/video_input.py

Summary

Maintainability
C
1 day
Test Coverage

File video_input.py has 349 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: Minor
Found in official/vision/dataloaders/video_input.py - About 4 hrs to fix

    Function process_image has 19 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def process_image(image: tf.Tensor,
    Severity: Major
    Found in official/vision/dataloaders/video_input.py - About 2 hrs to fix

      Function process_image has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def process_image(image: tf.Tensor,
                        is_training: bool = True,
                        num_frames: int = 32,
                        stride: int = 1,
                        random_stride_range: int = 0,
      Severity: Minor
      Found in official/vision/dataloaders/video_input.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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def __init__(self,
                     input_params: exp_cfg.DataConfig,
                     image_key: str = IMAGE_KEY,
                     label_key: str = LABEL_KEY):
          self._num_frames = input_params.feature_shape[0]
      Severity: Minor
      Found in official/vision/dataloaders/video_input.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def __init__(self,
                     input_params: exp_cfg.DataConfig,
                     image_key: str = IMAGE_KEY,
                     label_key: str = LABEL_KEY):
          self._num_frames = input_params.feature_shape[0]
      Severity: Minor
      Found in official/vision/dataloaders/video_input.py - About 1 hr to fix

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

        def postprocess_image(image: tf.Tensor,
        Severity: Minor
        Found in official/vision/dataloaders/video_input.py - About 35 mins to fix

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

          def process_label(label: tf.Tensor,
                            one_hot_label: bool = True,
                            num_classes: Optional[int] = None,
                            label_dtype: tf.DType = tf.int32) -> tf.Tensor:
            """Processes label Tensor."""
          Severity: Minor
          Found in official/vision/dataloaders/video_input.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