From de856de997c7295c48cdb05d3e1d1b5cd768da7e Mon Sep 17 00:00:00 2001 From: Xiaobin Zhang Date: Wed, 13 Nov 2019 15:03:03 +0800 Subject: [PATCH] add YOLOv2 predict layer name --- yolo2/models/yolo2_darknet.py | 4 ++-- yolo2/models/yolo2_mobilenet.py | 6 +++--- yolo2/models/yolo2_mobilenetv2.py | 8 ++++---- yolo2/models/yolo2_xception.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/yolo2/models/yolo2_darknet.py b/yolo2/models/yolo2_darknet.py index ed0448b..b591500 100644 --- a/yolo2/models/yolo2_darknet.py +++ b/yolo2/models/yolo2_darknet.py @@ -85,11 +85,11 @@ def tiny_yolo2_body(inputs, num_anchors, num_classes): if num_classes == 80: y = compose( DarknetConv2D_BN_Leaky(512, (3,3)), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(x) else: y = compose( DarknetConv2D_BN_Leaky(1024, (3,3)), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(x) return Model(inputs, y) diff --git a/yolo2/models/yolo2_mobilenet.py b/yolo2/models/yolo2_mobilenet.py index c0d00b0..521e592 100644 --- a/yolo2/models/yolo2_mobilenet.py +++ b/yolo2/models/yolo2_mobilenet.py @@ -34,7 +34,7 @@ def yolo2_mobilenet_body(inputs, num_anchors, num_classes, alpha=1.0): x = Concatenate()([conv_head2_reshaped, conv_head1]) x = DarknetConv2D_BN_Leaky(int(1024*alpha), (3, 3))(x) - x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x) + x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1), name='predict_conv')(x) return Model(inputs, x) @@ -74,7 +74,7 @@ def tiny_yolo2_mobilenet_body(inputs, num_anchors, num_classes, alpha=1.0): # mobilenet.output : 13 x 13 x (1024*alpha) y = compose( DarknetConv2D_BN_Leaky(int(1024*alpha), (3,3)), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(mobilenet.output) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(mobilenet.output) return Model(inputs, y) @@ -87,6 +87,6 @@ def tiny_yolo2lite_mobilenet_body(inputs, num_anchors, num_classes, alpha=1.0): # mobilenet.output : 13 x 13 x (1024*alpha) y = compose( Depthwise_Separable_Conv2D_BN_Leaky(int(1024*alpha), (3,3), block_id_str='14'), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(mobilenet.output) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(mobilenet.output) return Model(inputs, y) diff --git a/yolo2/models/yolo2_mobilenetv2.py b/yolo2/models/yolo2_mobilenetv2.py index 3bbaf5d..dc4cc13 100644 --- a/yolo2/models/yolo2_mobilenetv2.py +++ b/yolo2/models/yolo2_mobilenetv2.py @@ -34,7 +34,7 @@ def yolo2_mobilenetv2_body(inputs, num_anchors, num_classes, alpha=1.0): x = Concatenate()([conv_head2_reshaped, conv_head1]) x = DarknetConv2D_BN_Leaky(1280, (3, 3))(x) - x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x) + x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1), name='predict_conv')(x) return Model(inputs, x) @@ -62,7 +62,7 @@ def yolo2lite_mobilenetv2_body(inputs, num_anchors, num_classes, alpha=1.0): x = Concatenate()([conv_head2_reshaped, conv_head1]) x = Depthwise_Separable_Conv2D_BN_Leaky(1280, (3, 3))(x) - x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x) + x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1), name='predict_conv')(x) return Model(inputs, x) @@ -74,7 +74,7 @@ def tiny_yolo2_mobilenetv2_body(inputs, num_anchors, num_classes): # mobilenetv2.output : 13 x 13 x 1280 y = compose( DarknetConv2D_BN_Leaky(1280, (3,3)), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(mobilenetv2.output) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(mobilenetv2.output) return Model(inputs, y) @@ -87,6 +87,6 @@ def tiny_yolo2lite_mobilenetv2_body(inputs, num_anchors, num_classes): # mobilenetv2.output : 13 x 13 x 1280 y = compose( Depthwise_Separable_Conv2D_BN_Leaky(1280, (3,3)), - DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(mobilenetv2.output) + DarknetConv2D(num_anchors*(num_classes+5), (1,1), name='predict_conv'))(mobilenetv2.output) return Model(inputs, y) diff --git a/yolo2/models/yolo2_xception.py b/yolo2/models/yolo2_xception.py index d6db894..171ade1 100644 --- a/yolo2/models/yolo2_xception.py +++ b/yolo2/models/yolo2_xception.py @@ -33,7 +33,7 @@ def yolo2_xception_body(inputs, num_anchors, num_classes): x = Concatenate()([conv_head2_reshaped, conv_head1]) x = DarknetConv2D_BN_Leaky(2048, (3, 3))(x) - x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x) + x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1), name='predict_conv')(x) return Model(inputs, x) @@ -61,6 +61,6 @@ def yolo2lite_xception_body(inputs, num_anchors, num_classes): x = Concatenate()([conv_head2_reshaped, conv_head1]) x = Depthwise_Separable_Conv2D_BN_Leaky(2048, (3, 3))(x) - x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1))(x) + x = DarknetConv2D(num_anchors * (num_classes + 5), (1, 1), name='predict_conv')(x) return Model(inputs, x)