tensorflow/models

View on GitHub
research/object_detection/export_tflite_ssd_graph_lib.py

Summary

Maintainability
D
2 days
Test Coverage

File export_tflite_ssd_graph_lib.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# 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.
# You may obtain a copy of the License at
Severity: Minor
Found in research/object_detection/export_tflite_ssd_graph_lib.py - About 2 hrs to fix

    Function export_tflite_graph has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def export_tflite_graph(pipeline_config,
    Severity: Major
    Found in research/object_detection/export_tflite_ssd_graph_lib.py - About 1 hr to fix

      Function export_tflite_graph has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def export_tflite_graph(pipeline_config,
                              trained_checkpoint_prefix,
                              output_dir,
                              add_postprocessing_op,
                              max_detections,
      Severity: Minor
      Found in research/object_detection/export_tflite_ssd_graph_lib.py - About 1 hr to fix

        Function append_postprocessing_op has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def append_postprocessing_op(frozen_graph_def,
        Severity: Major
        Found in research/object_detection/export_tflite_ssd_graph_lib.py - About 1 hr to fix

          Function export_tflite_graph has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def export_tflite_graph(pipeline_config,
                                  trained_checkpoint_prefix,
                                  output_dir,
                                  add_postprocessing_op,
                                  max_detections,
          Severity: Minor
          Found in research/object_detection/export_tflite_ssd_graph_lib.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          def get_const_center_size_encoded_anchors(anchors):
            """Exports center-size encoded anchors as a constant tensor.
          
            Args:
              anchors: a float32 tensor of shape [num_anchors, 4] containing the anchor
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 1 other location - About 1 day to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 39..61

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

          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 pipeline_config.eval_config.use_moving_averages:
              saver_kwargs['write_version'] = saver_pb2.SaverDef.V1
              moving_average_checkpoint = tempfile.NamedTemporaryFile()
              exporter.replace_variable_values_with_moving_averages(
                  tf.get_default_graph(), trained_checkpoint_prefix,
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 1 other location - About 1 hr to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 285..291

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

          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

            with tf.name_scope('raw_outputs'):
              # 'raw_outputs/box_encodings': a float32 tensor of shape [1, num_anchors, 4]
              #  containing the encoded box predictions. Note that these are raw
              #  predictions and no Non-Max suppression is applied on them and
              #  no decode center size boxes is applied to them.
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 1 other location - About 1 hr to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 252..261

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

          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 8 locations. Consider refactoring.
          Open

            new_output.attr['h_scale'].CopyFrom(
                attr_value_pb2.AttrValue(f=scale_values['h_scale'].pop()))
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 7 other locations - About 45 mins to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 128..129
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 130..131
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 132..133
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 132..133
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 138..139

          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 8 locations. Consider refactoring.
          Open

            new_output.attr['y_scale'].CopyFrom(
                attr_value_pb2.AttrValue(f=scale_values['y_scale'].pop()))
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 7 other locations - About 45 mins to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 128..129
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 130..131
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 132..133
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 136..137
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 138..139

          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 8 locations. Consider refactoring.
          Open

            new_output.attr['x_scale'].CopyFrom(
                attr_value_pb2.AttrValue(f=scale_values['x_scale'].pop()))
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 7 other locations - About 45 mins to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 128..129
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 130..131
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 132..133
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 132..133
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 136..137
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 138..139

          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 8 locations. Consider refactoring.
          Open

            new_output.attr['w_scale'].CopyFrom(
                attr_value_pb2.AttrValue(f=scale_values['w_scale'].pop()))
          Severity: Major
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 7 other locations - About 45 mins to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 128..129
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 130..131
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 132..133
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 132..133
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 134..135
          research/object_detection/export_tflite_ssd_graph_lib.py on lines 136..137

          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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            new_output.attr['_output_types'].list.type.extend([
                types_pb2.DT_FLOAT, types_pb2.DT_FLOAT, types_pb2.DT_FLOAT,
                types_pb2.DT_FLOAT
          Severity: Minor
          Found in research/object_detection/export_tflite_ssd_graph_lib.py and 1 other location - About 40 mins to fix
          research/lstm_object_detection/export_tflite_lstd_graph_lib.py on lines 111..113

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

          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