Skip to content

Commit

Permalink
add YOLOv2 predict layer name
Browse files Browse the repository at this point in the history
  • Loading branch information
david8862 committed Nov 13, 2019
1 parent 87935ae commit de856de
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions yolo2/models/yolo2_darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

6 changes: 3 additions & 3 deletions yolo2/models/yolo2_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)

Expand All @@ -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)
8 changes: 4 additions & 4 deletions yolo2/models/yolo2_mobilenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand All @@ -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)

Expand All @@ -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)
4 changes: 2 additions & 2 deletions yolo2/models/yolo2_xception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)

0 comments on commit de856de

Please sign in to comment.