tensorflow/models

View on GitHub
official/projects/yolo/ops/anchor.py

Summary

Maintainability
D
2 days
Test Coverage

File anchor.py has 381 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/projects/yolo/ops/anchor.py - About 5 hrs to fix

    Function _get_anchor_free has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def _get_anchor_free(self, key, boxes, classes, height, width, stride,
                           center_radius):
        """Find the box assignements in an anchor free paradigm."""
        level_limits = self.anchor_free_level_limits[key]
        gen = loss_utils.GridGenerator(anchors=[[1, 1]], scale_anchors=stride)
    Severity: Minor
    Found in official/projects/yolo/ops/anchor.py - About 1 hr to fix

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

        def __init__(self,
      Severity: Major
      Found in official/projects/yolo/ops/anchor.py - About 1 hr to fix

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

        def get_best_anchor(y_true,
        Severity: Major
        Found in official/projects/yolo/ops/anchor.py - About 1 hr to fix

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

            def _get_anchor_id(self,
          Severity: Major
          Found in official/projects/yolo/ops/anchor.py - About 50 mins to fix

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

              def _get_anchor_free(self, key, boxes, classes, height, width, stride,
            Severity: Major
            Found in official/projects/yolo/ops/anchor.py - About 50 mins to fix

              Function _get_centers has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def _get_centers(self, boxes, classes, anchors, width, height, scale_xy):
              Severity: Minor
              Found in official/projects/yolo/ops/anchor.py - About 45 mins to fix

                Function build_label_per_path has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def build_label_per_path(self,
                Severity: Minor
                Found in official/projects/yolo/ops/anchor.py - About 45 mins to fix

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

                            ((indexes[..., 1:] + 1) * ind_mask[..., 1:]) - 1
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 55 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 103..103

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

                  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

                        iou_index = ((indexes[..., 0:] + 1) * ind_mask[..., 0:]) - 1
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 55 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 107..107

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

                  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

                      c_r = (boxes[..., 0] + center_radius * stride) - x_centers
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 30 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 360..360

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

                  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

                      c_t = y_centers - (boxes[..., 1] - center_radius * stride)
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 30 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 359..359

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

                  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

                      c_l = x_centers - (boxes[..., 0] - center_radius * stride)
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 30 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 358..358

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

                  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

                      c_b = (boxes[..., 1] + center_radius * stride) - y_centers
                  Severity: Minor
                  Found in official/projects/yolo/ops/anchor.py and 1 other location - About 30 mins to fix
                  official/projects/yolo/ops/anchor.py on lines 361..361

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

                  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