def yolo_body(inputs, num_anchors, num_classes):
    #net, endpoint = inception_v2.inception_v2(inputs)
    darknet = Model(inputs, darknet_ref_body(inputs))

    # input: 416 x 416 x 3
    # leaky_re_lu_7 :13 x 13 x 1024
    # leaky_re_lu_5 :26 x 26 x 512
    # leaky_re_lu_4 : 52 x 52 x 256

    f1 = darknet.get_layer('leaky_re_lu_7').output
    # f1 :13 x 13 x 1024
    x, y1 = make_last_layers(f1, 256, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(128, (1, 1)), UpSampling2D(2))(x)

    f2 = darknet.get_layer('leaky_re_lu_5').output
    # f2: 26 x 26 x 512
    x = Concatenate()([x, f2])

    x, y2 = make_last_layers(x, 128, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(64, (1, 1)), UpSampling2D(2))(x)

    f3 = darknet.get_layer('leaky_re_lu_4').output
    # f3 : 52 x 52 x 256
    x = Concatenate()([x, f3])
    x, y3 = make_last_layers(x, 64, num_anchors * (num_classes + 5))

    return Model(inputs=inputs, outputs=[y1, y2, y3])
def mobilenetv2_yolo_body(inputs, num_anchors, num_classes):
    #net, endpoint = inception_v2.inception_v2(inputs)
    mobilenet = MobileNetV2(input_tensor=inputs, weights='imagenet')

    # input: 416 x 416 x 3
    # conv_pw_13_relu :13 x 13 x 1024
    # conv_pw_11_relu :26 x 26 x 512
    # conv_pw_5_relu : 52 x 52 x 256

    f1 = mobilenet.get_layer('out_relu').output
    # f1 :13 x 13 x 1024
    x, y1 = make_last_layers(f1, 512, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(256, (1, 1)), UpSampling2D(2))(x)

    f2 = mobilenet.get_layer('block_13_expand_relu').output
    # f2: 26 x 26 x 512
    x = Concatenate()([x, f2])

    x, y2 = make_last_layers(x, 256, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(128, (1, 1)), UpSampling2D(2))(x)

    f3 = mobilenet.get_layer('block_6_expand_relu').output
    # f3 : 52 x 52 x 256
    x = Concatenate()([x, f3])
    x, y3 = make_last_layers(x, 128, num_anchors * (num_classes + 5))

    return Model(inputs=inputs, outputs=[y1, y2, y3])
예제 #3
0
def yolo_body(inputs, num_anchors, num_classes):
    #net, endpoint = inception_v2.inception_v2(inputs)
    squeezenet = squeezenet_body(input_tensor=inputs)

    # input: 416 x 416 x 3
    # contatenate_10 :12 x 12 x 640
    # contatenate_6 :25 x 25 x 384
    # contatenate_4 : 51 x 51 x 256

    f1 = squeezenet.get_layer('concatenate_10').output
    # f1 :13 x 13 x 1024
    x, y1 = make_last_layers(f1, 512, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(256, (1, 1)), UpSampling2D(2))(x)

    f2 = squeezenet.get_layer('concatenate_6').output
    # f2: 26 x 26 x 512
    x = Concatenate()([x, f2])

    x, y2 = make_last_layers(x, 256, num_anchors * (num_classes + 5))

    x = compose(DarknetConv2D_BN_Leaky(128, (1, 1)), UpSampling2D(2))(x)

    f3 = squeezenet.get_layer('concatenate_4').output
    # f3 : 52 x 52 x 256
    x = Concatenate()([x, f3])
    x, y3 = make_last_layers(x, 128, num_anchors * (num_classes + 5))

    return Model(inputs=inputs, outputs=[y1, y2, y3])