tensorflow/models

View on GitHub
official/legacy/detection/ops/target_ops.py

Summary

Maintainability
F
3 days
Test Coverage

File target_ops.py has 479 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/ops/target_ops.py - About 7 hrs to fix

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

      def assign_and_sample_proposals_and_scores(self,
    Severity: Major
    Found in official/legacy/detection/ops/target_ops.py - About 1 hr to fix

      Function assign_and_sample_proposals has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def assign_and_sample_proposals(proposed_boxes,
      Severity: Major
      Found in official/legacy/detection/ops/target_ops.py - About 1 hr to fix

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

        def sample_and_crop_foreground_masks(candidate_rois,
        Severity: Major
        Found in official/legacy/detection/ops/target_ops.py - About 50 mins to fix

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

            def call(self,
          Severity: Minor
          Found in official/legacy/detection/ops/target_ops.py - About 35 mins to fix

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

                  batch_indices = (
                      tf.expand_dims(tf.range(sampled_indices_shape[0]), axis=-1) *
                      tf.ones([1, sampled_indices_shape[-1]], dtype=tf.int32))
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 5 other locations - About 2 hrs to fix
            official/legacy/detection/ops/target_ops.py on lines 78..80
            official/legacy/detection/ops/target_ops.py on lines 202..204
            official/legacy/detection/ops/target_ops.py on lines 263..265
            official/legacy/detection/ops/target_ops.py on lines 278..280
            official/legacy/detection/utils/box_utils.py on lines 634..636

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

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

              batch_indices = (
                  tf.expand_dims(tf.range(argmax_iou_indices_shape[0]), axis=-1) *
                  tf.ones([1, argmax_iou_indices_shape[-1]], dtype=tf.int32))
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 5 other locations - About 2 hrs to fix
            official/legacy/detection/ops/target_ops.py on lines 202..204
            official/legacy/detection/ops/target_ops.py on lines 263..265
            official/legacy/detection/ops/target_ops.py on lines 278..280
            official/legacy/detection/ops/target_ops.py on lines 505..507
            official/legacy/detection/utils/box_utils.py on lines 634..636

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

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

                batch_indices = (
                    tf.expand_dims(tf.range(foreground_gt_indices_shape[0]), axis=-1) *
                    tf.ones([1, foreground_gt_indices_shape[-1]], dtype=tf.int32))
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 5 other locations - About 2 hrs to fix
            official/legacy/detection/ops/target_ops.py on lines 78..80
            official/legacy/detection/ops/target_ops.py on lines 202..204
            official/legacy/detection/ops/target_ops.py on lines 263..265
            official/legacy/detection/ops/target_ops.py on lines 505..507
            official/legacy/detection/utils/box_utils.py on lines 634..636

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

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

                batch_indices = (
                    tf.expand_dims(tf.range(fg_instance_indices_shape[0]), axis=-1) *
                    tf.ones([1, fg_instance_indices_shape[-1]], dtype=tf.int32))
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 5 other locations - About 2 hrs to fix
            official/legacy/detection/ops/target_ops.py on lines 78..80
            official/legacy/detection/ops/target_ops.py on lines 202..204
            official/legacy/detection/ops/target_ops.py on lines 278..280
            official/legacy/detection/ops/target_ops.py on lines 505..507
            official/legacy/detection/utils/box_utils.py on lines 634..636

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

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

                batch_indices = (
                    tf.expand_dims(tf.range(sampled_indices_shape[0]), axis=-1) *
                    tf.ones([1, sampled_indices_shape[-1]], dtype=tf.int32))
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 5 other locations - About 2 hrs to fix
            official/legacy/detection/ops/target_ops.py on lines 78..80
            official/legacy/detection/ops/target_ops.py on lines 263..265
            official/legacy/detection/ops/target_ops.py on lines 278..280
            official/legacy/detection/ops/target_ops.py on lines 505..507
            official/legacy/detection/utils/box_utils.py on lines 634..636

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

            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

                  for i in range(batch_size):
                    sampled_indicator = sampler.subsample(sample_candidates[i],
                                                          num_samples_per_image,
                                                          positive_match[i])
                    sampled_indicators.append(sampled_indicator)
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 1 other location - About 1 hr to fix
            official/legacy/detection/ops/target_ops.py on lines 190..194

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

                for i in range(batch_size):
                  sampled_indicator = sampler.subsample(sample_candidates[i],
                                                        num_samples_per_image,
                                                        positive_match[i])
                  sampled_indicators.append(sampled_indicator)
            Severity: Major
            Found in official/legacy/detection/ops/target_ops.py and 1 other location - About 1 hr to fix
            official/legacy/detection/ops/target_ops.py on lines 493..497

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

                _, sampled_indices = tf.nn.top_k(
                    tf.cast(sampled_indicators, dtype=tf.int32),
            Severity: Minor
            Found in official/legacy/detection/ops/target_ops.py and 1 other location - About 45 mins to fix
            official/legacy/detection/ops/target_ops.py on lines 499..500

            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

                  _, sampled_indices = tf.nn.top_k(
                      tf.cast(sampled_indicators, dtype=tf.int32),
            Severity: Minor
            Found in official/legacy/detection/ops/target_ops.py and 1 other location - About 45 mins to fix
            official/legacy/detection/ops/target_ops.py on lines 196..197

            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