tensorflow/models

View on GitHub
research/deeplab/core/feature_extractor.py

Summary

Maintainability
F
1 wk
Test Coverage

File feature_extractor.py has 617 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Lint as: python2, python3
# Copyright 2018 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.
Severity: Major
Found in research/deeplab/core/feature_extractor.py - About 1 day to fix

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

    def extract_features(images,
    Severity: Major
    Found in research/deeplab/core/feature_extractor.py - About 2 hrs to fix

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

      def extract_features(images,
                           output_stride=8,
                           multi_grid=None,
                           depth_multiplier=1.0,
                           divisible_by=None,
      Severity: Minor
      Found in research/deeplab/core/feature_extractor.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 _mobilenet_v3 has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _mobilenet_v3(net,
      Severity: Major
      Found in research/deeplab/core/feature_extractor.py - About 1 hr to fix

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

        def _mobilenet_v2(net,
        Severity: Major
        Found in research/deeplab/core/feature_extractor.py - About 1 hr to fix

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

          def mobilenet_edgetpu(net,
          Severity: Major
          Found in research/deeplab/core/feature_extractor.py - About 50 mins to fix

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

            def mobilenet_v3_small_seg(net,
            Severity: Major
            Found in research/deeplab/core/feature_extractor.py - About 50 mins to fix

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

              def mobilenet_v2_arg_scope(is_training=True,
              Severity: Major
              Found in research/deeplab/core/feature_extractor.py - About 50 mins to fix

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

                def mobilenet_v3_large_seg(net,
                Severity: Major
                Found in research/deeplab/core/feature_extractor.py - About 50 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                    if 'resnet' in model_variant:
                      arg_scope = arg_scopes_map[model_variant](
                          weight_decay=weight_decay,
                          batch_norm_decay=0.95,
                          batch_norm_epsilon=1e-5,
                  Severity: Major
                  Found in research/deeplab/core/feature_extractor.py - About 40 mins to fix

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

                    def mobilenet_v2_arg_scope(is_training=True,
                                               weight_decay=0.00004,
                                               stddev=0.09,
                                               activation=tf.nn.relu6,
                                               bn_decay=0.997,
                    Severity: Minor
                    Found in research/deeplab/core/feature_extractor.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 _mobilenet_v2 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _mobilenet_v2(net,
                                      depth_multiplier,
                                      output_stride,
                                      conv_defs=None,
                                      divisible_by=None,
                    Severity: Minor
                    Found in research/deeplab/core/feature_extractor.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 mobilenet_v3_small_seg(net,
                                               depth_multiplier,
                                               output_stride,
                                               divisible_by=None,
                                               reuse=None,
                    Severity: Major
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 1 day to fix
                    research/deeplab/core/feature_extractor.py on lines 144..165

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

                    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 mobilenet_v3_large_seg(net,
                                               depth_multiplier,
                                               output_stride,
                                               divisible_by=None,
                                               reuse=None,
                    Severity: Major
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 1 day to fix
                    research/deeplab/core/feature_extractor.py on lines 199..220

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

                    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

                    networks_map = {
                        'mobilenet_v2': _mobilenet_v2,
                        'mobilenet_edgetpu': mobilenet_edgetpu,
                        'mobilenet_v3_large_seg': mobilenet_v3_large_seg,
                        'mobilenet_v3_small_seg': mobilenet_v3_small_seg,
                    Severity: Major
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 2 hrs to fix
                    research/object_detection/builders/model_builder.py on lines 103..129

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

                    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

                        features, end_points = get_network(
                            model_variant, preprocess_images, preprocessed_images_dtype, arg_scope)(
                                inputs=images,
                                num_classes=num_classes,
                                is_training=(is_training and fine_tune_batch_norm),
                    Severity: Major
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 2 hrs to fix
                    research/deeplab/core/feature_extractor.py on lines 662..672

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

                    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

                        features, end_points = get_network(
                            model_variant, preprocess_images, preprocessed_images_dtype, arg_scope)(
                                inputs=images,
                                num_classes=num_classes,
                                is_training=(is_training and fine_tune_batch_norm),
                    Severity: Major
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 2 hrs to fix
                    research/deeplab/core/feature_extractor.py on lines 633..643

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

                    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 stddev < 0:
                        weight_intitializer = slim.initializers.xavier_initializer()
                      else:
                        weight_intitializer = tf.truncated_normal_initializer(stddev=stddev)
                    Severity: Minor
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 45 mins to fix
                    research/slim/nets/mobilenet/mobilenet.py on lines 470..473

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

                    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

                    _PREPROCESS_FN = {
                        'mobilenet_v2': _preprocess_zero_mean_unit_range,
                        'mobilenet_edgetpu': _preprocess_zero_mean_unit_range,
                        'mobilenet_v3_large_seg': _preprocess_zero_mean_unit_range,
                        'mobilenet_v3_small_seg': _preprocess_zero_mean_unit_range,
                    Severity: Minor
                    Found in research/deeplab/core/feature_extractor.py and 1 other location - About 35 mins to fix
                    official/projects/yolo/modeling/layers/nn_blocks.py on lines 1202..1217

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

                    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