File deepmac_meta_arch.py
has 1629 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Deep Mask heads above CenterNet (DeepMAC)[1] architecture.
[1]: https://arxiv.org/abs/2104.00613
"""
Function _get_deepmac_network_by_type
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _get_deepmac_network_by_type(name, num_init_channels, mask_size=None):
"""Get DeepMAC network model given a string type."""
if name.startswith('hourglass'):
if name == 'hourglass10':
- 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 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function _compute_deepmac_losses
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def _compute_deepmac_losses(
Function transform_images_and_boxes
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def transform_images_and_boxes(images, boxes, tx, ty, sx, sy, flip):
Function transform_instance_masks
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def transform_instance_masks(instance_masks, tx, ty, sx, sy, flip):
Function _self_supervision_loss
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _self_supervision_loss(
Function predict_masks_from_boxes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def predict_masks_from_boxes(self, prediction_dict, true_image_shapes,
Function _aggregate_classification_loss
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _aggregate_classification_loss(self, loss, gt, pred, method):
Function _transform_boxes_to_feature_coordinates
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _transform_boxes_to_feature_coordinates(self, provided_boxes,
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, network_type, num_init_channels=64,
Function _compute_mask_prediction_loss
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _compute_mask_prediction_loss(
Function subsample_instances
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def subsample_instances(classes, weights, boxes, masks, num_subsamples):
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, resnet_type, num_init_channels):
"""Creates the ResNet mask network.
Args:
resnet_type: A string of the for resnetN where N where N is in
- 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 too many return
statements within this function. Open
return ResNetMaskNetwork(name, num_init_channels)
Avoid too many return
statements within this function. Open
return hourglass_network.hourglass_20_no_shortcut(num_init_channels)
Avoid too many return
statements within this function. Open
return tf.keras.layers.Lambda(lambda x: x)
Avoid too many return
statements within this function. Open
return config.pointly_supervised_keypoint_loss_weight
Avoid too many return
statements within this function. Open
return hourglass_network.hourglass_20_uniform_size(num_init_channels)
Avoid too many return
statements within this function. Open
return hourglass_network.hourglass_100(num_init_channels,
Avoid too many return
statements within this function. Open
return FullyConnectedMaskHead(num_init_channels, mask_size)
Function _get_loss_weight
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_loss_weight(loss_name, config):
"""Utility function to get loss weights by name."""
if loss_name == DEEP_MASK_ESTIMATION:
return config.task_loss_weight
elif loss_name == DEEP_MASK_FEATURE_CONSISTENCY:
- 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"