Function convert_groundtruths_to_coco_dataset
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
def convert_groundtruths_to_coco_dataset(groundtruths, label_map=None):
"""Converts ground-truths to the dataset in COCO format.
Args:
groundtruths: a dictionary of numpy arrays including the fields below.
- Read upRead up
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
File coco_utils.py
has 365 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
Function convert_predictions_to_coco_annotations
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def convert_predictions_to_coco_annotations(predictions):
"""Converts a batch of predictions to annotations in COCO format.
Args:
predictions: a dictionary of lists of numpy arrays including the following
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if isinstance(groundtruths['masks'][i][j, k], tf.Tensor):
mask = Image.open(
six.BytesIO(groundtruths['masks'][i][j, k].numpy()))
else:
mask = Image.open(
Avoid deeply nested control flow statements. Open
if 'counts' in ann['segmentation']:
ann['segmentation']['counts'] = six.ensure_str(
ann['segmentation']['counts'])
if 'areas' not in groundtruths:
Avoid deeply nested control flow statements. Open
if 'areas' not in groundtruths:
ann['area'] = mask_api.area(encoded_mask)
if 'keypoints' in groundtruths:
Function scan_and_generator_annotation_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def scan_and_generator_annotation_file(file_pattern: str,
Avoid deeply nested control flow statements. Open
for z in range(len(keypoints[j, k, :, 1])):
# Convert from [y, x] to [x, y] as mandated by COCO.
x = float(keypoints[j, k, z, 1])
y = float(keypoints[j, k, z, 0])
coco_keypoints.append(x)
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, file_pattern, file_type, num_examples, include_mask,
Function generate_annotation_file
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def generate_annotation_file(groundtruth_generator,
annotation_file):
"""Generates COCO-style annotation JSON file given a ground-truth generator."""
groundtruths = {}
logging.info('Loading groundtruth annotations from dataset to memory...')
- Read upRead up
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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, eval_type='box', annotation_file=None, gt_dataset=None):
"""Instantiates a COCO-style API object.
Args:
eval_type: either 'box' or 'mask'.
- Read upRead up
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"