提交 1b3f08eb 编写于 作者: W Waleed Abdulla

Convert config.BACKBONE_SHAPES to a function.

上级 a243f78d
......@@ -169,12 +169,6 @@ class Config(object):
self.IMAGE_SHAPE = np.array(
[self.IMAGE_MAX_DIM, self.IMAGE_MAX_DIM, 3])
# Compute backbone size from input image size
self.BACKBONE_SHAPES = np.array(
[[int(math.ceil(self.IMAGE_SHAPE[0] / stride)),
int(math.ceil(self.IMAGE_SHAPE[1] / stride))]
for stride in self.BACKBONE_STRIDES])
# Image meta data length
# See compose_image_meta() for details
self.IMAGE_META_SIZE = 1 + 3 + 3 + 4 + 1 + self.NUM_CLASSES
......
......@@ -73,6 +73,20 @@ class BatchNorm(KL.BatchNormalization):
return super(self.__class__, self).call(inputs, training=training)
def compute_backbone_shapes(config, image_shape):
"""Computes the width and height of each stage of the backbone network.
Returns:
[N, (height, width)]. Where N is the number of stages
"""
# Currently supports ResNet only
assert config.BACKBONE in ["resnet50", "resnet101"]
return np.array(
[[int(math.ceil(image_shape[0] / stride)),
int(math.ceil(image_shape[1] / stride))]
for stride in config.BACKBONE_STRIDES])
############################################################
# Resnet Graph
############################################################
......@@ -1663,9 +1677,10 @@ def data_generator(dataset, config, shuffle=True, augment=False, augmentation=No
# Anchors
# [anchor_count, (y1, x1, y2, x2)]
backbone_shapes = compute_backbone_shapes(config, config.IMAGE_SHAPE)
anchors = utils.generate_pyramid_anchors(config.RPN_ANCHOR_SCALES,
config.RPN_ANCHOR_RATIOS,
config.BACKBONE_SHAPES,
backbone_shapes,
config.BACKBONE_STRIDES,
config.RPN_ANCHOR_STRIDE)
......@@ -1897,9 +1912,10 @@ class MaskRCNN():
mrcnn_feature_maps = [P2, P3, P4, P5]
# Generate Anchors
backbone_shapes = compute_backbone_shapes(config, config.IMAGE_SHAPE)
self.anchors = utils.generate_pyramid_anchors(config.RPN_ANCHOR_SCALES,
config.RPN_ANCHOR_RATIOS,
config.BACKBONE_SHAPES,
backbone_shapes,
config.BACKBONE_STRIDES,
config.RPN_ANCHOR_STRIDE)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册