mirror of
https://gitlab.com/bukanrahasia/MaskRCNN-RGBD.git
synced 2023-12-14 04:02:57 +01:00
Naming every copied layer
This commit is contained in:
parent
6ed4ec7c21
commit
5fe7001ed0
1 changed files with 17 additions and 17 deletions
|
@ -168,7 +168,7 @@ def conv_block(input_tensor, kernel_size, filters, stage, block,
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
def resnet_graph(input_image, architecture, stage5=False, train_bn=True):
|
def resnet_graph(input_image, architecture, stage5=False, train_bn=True, cn=""):
|
||||||
"""Build a ResNet graph.
|
"""Build a ResNet graph.
|
||||||
architecture: Can be resnet50 or resnet101
|
architecture: Can be resnet50 or resnet101
|
||||||
stage5: Boolean. If False, stage5 of the network is not created
|
stage5: Boolean. If False, stage5 of the network is not created
|
||||||
|
@ -177,30 +177,30 @@ def resnet_graph(input_image, architecture, stage5=False, train_bn=True):
|
||||||
assert architecture in ["resnet50", "resnet101"]
|
assert architecture in ["resnet50", "resnet101"]
|
||||||
# Stage 1
|
# Stage 1
|
||||||
x = KL.ZeroPadding2D((3, 3))(input_image)
|
x = KL.ZeroPadding2D((3, 3))(input_image)
|
||||||
x = KL.Conv2D(64, (7, 7), strides=(2, 2), name='conv1', use_bias=True)(x)
|
x = KL.Conv2D(64, (7, 7), strides=(2, 2), name='conv1' + cn, use_bias=True)(x)
|
||||||
x = BatchNorm(name='bn_conv1')(x, training=train_bn)
|
x = BatchNorm(name='bn_conv1' + cn)(x, training=train_bn)
|
||||||
x = KL.Activation('relu')(x)
|
x = KL.Activation('relu')(x)
|
||||||
C1 = x = KL.MaxPooling2D((3, 3), strides=(2, 2), padding="same")(x)
|
C1 = x = KL.MaxPooling2D((3, 3), strides=(2, 2), padding="same")(x)
|
||||||
# Stage 2
|
# Stage 2
|
||||||
x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1), train_bn=train_bn)
|
x = conv_block(x, 3, [64, 64, 256], stage=2, block='a' + cn, strides=(1, 1), train_bn=train_bn)
|
||||||
x = identity_block(x, 3, [64, 64, 256], stage=2, block='b', train_bn=train_bn)
|
x = identity_block(x, 3, [64, 64, 256], stage=2, block='b' + cn, train_bn=train_bn)
|
||||||
C2 = x = identity_block(x, 3, [64, 64, 256], stage=2, block='c', train_bn=train_bn)
|
C2 = x = identity_block(x, 3, [64, 64, 256], stage=2, block='c' + cn, train_bn=train_bn)
|
||||||
# Stage 3
|
# Stage 3
|
||||||
x = conv_block(x, 3, [128, 128, 512], stage=3, block='a', train_bn=train_bn)
|
x = conv_block(x, 3, [128, 128, 512], stage=3, block='a' + cn, train_bn=train_bn)
|
||||||
x = identity_block(x, 3, [128, 128, 512], stage=3, block='b', train_bn=train_bn)
|
x = identity_block(x, 3, [128, 128, 512], stage=3, block='b' + cn, train_bn=train_bn)
|
||||||
x = identity_block(x, 3, [128, 128, 512], stage=3, block='c', train_bn=train_bn)
|
x = identity_block(x, 3, [128, 128, 512], stage=3, block='c' + cn, train_bn=train_bn)
|
||||||
C3 = x = identity_block(x, 3, [128, 128, 512], stage=3, block='d', train_bn=train_bn)
|
C3 = x = identity_block(x, 3, [128, 128, 512], stage=3, block='d' + cn, train_bn=train_bn)
|
||||||
# Stage 4
|
# Stage 4
|
||||||
x = conv_block(x, 3, [256, 256, 1024], stage=4, block='a', train_bn=train_bn)
|
x = conv_block(x, 3, [256, 256, 1024], stage=4, block='a' + cn, train_bn=train_bn)
|
||||||
block_count = {"resnet50": 5, "resnet101": 22}[architecture]
|
block_count = {"resnet50": 5, "resnet101": 22}[architecture]
|
||||||
for i in range(block_count):
|
for i in range(block_count):
|
||||||
x = identity_block(x, 3, [256, 256, 1024], stage=4, block=chr(98 + i), train_bn=train_bn)
|
x = identity_block(x, 3, [256, 256, 1024], stage=4, block=chr(98 + i) + cn, train_bn=train_bn)
|
||||||
C4 = x
|
C4 = x
|
||||||
# Stage 5
|
# Stage 5
|
||||||
if stage5:
|
if stage5:
|
||||||
x = conv_block(x, 3, [512, 512, 2048], stage=5, block='a', train_bn=train_bn)
|
x = conv_block(x, 3, [512, 512, 2048], stage=5, block='a' + cn, train_bn=train_bn)
|
||||||
x = identity_block(x, 3, [512, 512, 2048], stage=5, block='b', train_bn=train_bn)
|
x = identity_block(x, 3, [512, 512, 2048], stage=5, block='b' + cn, train_bn=train_bn)
|
||||||
C5 = x = identity_block(x, 3, [512, 512, 2048], stage=5, block='c', train_bn=train_bn)
|
C5 = x = identity_block(x, 3, [512, 512, 2048], stage=5, block='c' + cn, train_bn=train_bn)
|
||||||
else:
|
else:
|
||||||
C5 = None
|
C5 = None
|
||||||
return [C1, C2, C3, C4, C5]
|
return [C1, C2, C3, C4, C5]
|
||||||
|
@ -1907,9 +1907,9 @@ class MaskRCNN():
|
||||||
train_bn=config.TRAIN_BN)
|
train_bn=config.TRAIN_BN)
|
||||||
else:
|
else:
|
||||||
_, C2, C3, C4, C5 = resnet_graph(S_RGB, config.BACKBONE,
|
_, C2, C3, C4, C5 = resnet_graph(S_RGB, config.BACKBONE,
|
||||||
stage5=True, train_bn=config.TRAIN_BN)
|
stage5=True, train_bn=config.TRAIN_BN, cn="RGB")
|
||||||
_, C2D, C3D, C4D, C5D = resnet_graph(S_DEPTH, config.BACKBONE,
|
_, C2D, C3D, C4D, C5D = resnet_graph(S_DEPTH, config.BACKBONE,
|
||||||
stage5=True, train_bn=config.TRAIN_BN)
|
stage5=True, train_bn=config.TRAIN_BN, cn="DEPTH")
|
||||||
|
|
||||||
# Top-down Layers
|
# Top-down Layers
|
||||||
# TODO: add assert to varify feature map sizes match what's in config
|
# TODO: add assert to varify feature map sizes match what's in config
|
||||||
|
|
Loading…
Reference in a new issue