tensorflow/models

View on GitHub
official/legacy/detection/dataloader/retinanet_parser.py

Summary

Maintainability
F
4 days
Test Coverage

File retinanet_parser.py has 323 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/legacy/detection/dataloader/retinanet_parser.py - About 3 hrs to fix

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

      def __init__(self,
    Severity: Major
    Found in official/legacy/detection/dataloader/retinanet_parser.py - About 2 hrs to fix

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

      def process_source_id(source_id):
        """Processes source_id to the right format."""
        if source_id.dtype == tf.string:
          source_id = tf.cast(tf.strings.to_number(source_id), tf.int32)
        with tf.control_dependencies([source_id]):
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 1 other location - About 1 day to fix
      official/legacy/detection/utils/dataloader_utils.py on lines 22..31

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

      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

      def pad_groundtruths_to_fixed_size(gt, n):
        """Pads the first dimension of groundtruths labels to the fixed size."""
        gt['boxes'] = input_utils.pad_to_fixed_size(gt['boxes'], n, -1)
        gt['is_crowds'] = input_utils.pad_to_fixed_size(gt['is_crowds'], n, 0)
        gt['areas'] = input_utils.pad_to_fixed_size(gt['areas'], n, -1)
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 1 other location - About 7 hrs to fix
      official/legacy/detection/utils/dataloader_utils.py on lines 34..40

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

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

          if mode == ModeKeys.TRAIN:
            self._parse_fn = self._parse_train_data
          elif mode == ModeKeys.EVAL:
            self._parse_fn = self._parse_eval_data
          elif mode == ModeKeys.PREDICT or mode == ModeKeys.PREDICT_WITH_GT:
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 2 other locations - About 5 hrs to fix
      official/legacy/detection/dataloader/maskrcnn_parser.py on lines 121..128
      official/legacy/detection/dataloader/shapemask_parser.py on lines 184..191

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

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

          image, image_info = input_utils.resize_and_crop_image(
              image,
              self._output_size,
              padded_size=input_utils.compute_padded_size(self._output_size,
                                                          2**self._max_level),
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 2 other locations - About 1 hr to fix
      official/legacy/detection/dataloader/maskrcnn_parser.py on lines 220..226
      official/legacy/detection/dataloader/olnmask_parser.py on lines 211..217

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

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

          image, image_info = input_utils.resize_and_crop_image(
              image,
              self._output_size,
              padded_size=input_utils.compute_padded_size(self._output_size,
                                                          2**self._max_level),
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 2 other locations - About 1 hr to fix
      official/legacy/detection/dataloader/maskrcnn_parser.py on lines 334..338
      official/legacy/detection/dataloader/retinanet_parser.py on lines 291..295

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

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

          image, image_info = input_utils.resize_and_crop_image(
              image,
              self._output_size,
              padded_size=input_utils.compute_padded_size(self._output_size,
                                                          2**self._max_level),
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 2 other locations - About 1 hr to fix
      official/legacy/detection/dataloader/maskrcnn_parser.py on lines 334..338
      official/legacy/detection/dataloader/retinanet_parser.py on lines 365..369

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

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

        def __call__(self, value):
          """Parses data to an image and associated training labels.
      
          Args:
            value: a string tensor holding a serialized tf.Example proto.
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 2 other locations - About 1 hr to fix
      official/legacy/detection/dataloader/maskrcnn_parser.py on lines 130..143
      official/legacy/detection/dataloader/shapemask_parser.py on lines 193..248

      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

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

          (cls_targets, box_targets, num_positives) = anchor_labeler.label_anchors(
              boxes, tf.cast(tf.expand_dims(classes, axis=1), tf.float32))
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 4 other locations - About 45 mins to fix
      official/legacy/detection/dataloader/retinanet_parser.py on lines 316..317
      official/legacy/detection/dataloader/retinanet_parser.py on lines 420..421
      official/legacy/detection/dataloader/shapemask_parser.py on lines 313..317
      official/legacy/detection/dataloader/shapemask_parser.py on lines 503..507

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

          (cls_targets, box_targets, num_positives) = anchor_labeler.label_anchors(
              boxes, tf.cast(tf.expand_dims(classes, axis=1), tf.float32))
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 4 other locations - About 45 mins to fix
      official/legacy/detection/dataloader/retinanet_parser.py on lines 257..258
      official/legacy/detection/dataloader/retinanet_parser.py on lines 420..421
      official/legacy/detection/dataloader/shapemask_parser.py on lines 313..317
      official/legacy/detection/dataloader/shapemask_parser.py on lines 503..507

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

            (cls_targets, box_targets, num_positives) = anchor_labeler.label_anchors(
                boxes, tf.cast(tf.expand_dims(classes, axis=1), tf.float32))
      Severity: Major
      Found in official/legacy/detection/dataloader/retinanet_parser.py and 4 other locations - About 45 mins to fix
      official/legacy/detection/dataloader/retinanet_parser.py on lines 257..258
      official/legacy/detection/dataloader/retinanet_parser.py on lines 316..317
      official/legacy/detection/dataloader/shapemask_parser.py on lines 313..317
      official/legacy/detection/dataloader/shapemask_parser.py on lines 503..507

      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

      There are no issues that match your filters.

      Category
      Status