def TruncatedMobileNet(input_height, input_width):
    assert input_height // 16 * 16 == input_height
    assert input_width // 16 * 16 == input_width
    alpha = 1.0
    depth_multiplier = 1
    img_input = Input(shape=[input_height, input_width, 3], name='image_input')
    # s / 2
    x = _conv_block(img_input, 32, alpha, strides=(2, 2))
    x_s2 = _depthwise_conv_block(x, 64, alpha, depth_multiplier, block_id=1)
    # s / 4
    x = _depthwise_conv_block(x_s2, 128, alpha, depth_multiplier,
                              strides=(2, 2), block_id=2)
    x_s4 = _depthwise_conv_block(x, 128, alpha, depth_multiplier, block_id=3)
    # s /  8
    x = _depthwise_conv_block(x_s4, 256, alpha, depth_multiplier,
                              strides=(2, 2), block_id=4)
    x_s8 = _depthwise_conv_block(x, 256, alpha, depth_multiplier, block_id=5)
    # s / 16
    # DONE(see--): Make some of these dilated
    x = _depthwise_conv_block(x_s8, 512, alpha, depth_multiplier,
                              strides=(2, 2), block_id=6)
    x = _depthwise_conv_block(
        x, 512, alpha, depth_multiplier, dilation_rate=1, block_id=7)
    x = _depthwise_conv_block(
        x, 512, alpha, depth_multiplier, dilation_rate=1, block_id=8)
    x = _depthwise_conv_block(
        x, 512, alpha, depth_multiplier, dilation_rate=2, block_id=9)
    x = _depthwise_conv_block(
        x, 512, alpha, depth_multiplier, dilation_rate=4, block_id=10)
    x_s16 = _depthwise_conv_block(
        x, 512, alpha, depth_multiplier, dilation_rate=4, block_id=11)

    return img_input, x_s2, x_s4, x_s8, x_s16
Beispiel #2
0
def My_MobileNet(triplet, alpha=1.0, depth_multiplier=1):
    img_input = triplet
    x = _conv_block(img_input, 32, alpha, strides=(2, 2))
    x = _depthwise_conv_block(x, 64, alpha, depth_multiplier, block_id=1)

    x = _depthwise_conv_block(x,
                              128,
                              alpha,
                              depth_multiplier,
                              strides=(2, 2),
                              block_id=2)
    x = _depthwise_conv_block(x, 128, alpha, depth_multiplier, block_id=3)

    x = _depthwise_conv_block(x,
                              256,
                              alpha,
                              depth_multiplier,
                              strides=(2, 2),
                              block_id=4)
    x = _depthwise_conv_block(x, 256, alpha, depth_multiplier, block_id=5)

    x = _depthwise_conv_block(x,
                              512,
                              alpha,
                              depth_multiplier,
                              strides=(2, 2),
                              block_id=6)
    x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=7)
    x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=8)
    x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=9)
    x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=10)
    x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=11)

    x = _depthwise_conv_block(x,
                              1024,
                              alpha,
                              depth_multiplier,
                              strides=(2, 2),
                              block_id=12)
    x = _depthwise_conv_block(x, 1024, alpha, depth_multiplier, block_id=13)

    x = GlobalAveragePooling2D()(x)
    x = Flatten()(x)
    x = Dense(128)(x)

    return x
Beispiel #3
0
def MobileNetSlim(input_shape, alpha, depth_multiplier=1, output_classes=1, dropout=0.4):
	input = Input(shape=input_shape, name='flow')

	x = _conv_block(input, 32, alpha, strides=(2, 2))
	x = _depthwise_conv_block(x, 64, alpha, depth_multiplier, block_id=1)

	x = _depthwise_conv_block(x, 128, alpha, depth_multiplier, strides=(2, 2), block_id=2)
	x = _depthwise_conv_block(x, 128, alpha, depth_multiplier, block_id=3)

	x = _depthwise_conv_block(x, 256, alpha, depth_multiplier, strides=(2, 2), block_id=4)
	x1 = _depthwise_conv_block(x, 256, alpha, depth_multiplier, block_id=5)

	x = GlobalMaxPooling2D()(x)
	x = Dense(64, kernel_regularizer=regularizers.l2(0.01))(x)
	x = Activation('elu')(x)
	output = Dense(1, name='speed')(x)

	model = Model(inputs=input, outputs=output, name='optical_flow_encoder')
	return model
def mobilenet_block(x, weight_decay, palpha=1.0, depth_multiplier=1):
    x = _conv_block(x, 32, palpha, strides=(2, 2))
    x = _depthwise_conv_block_mod(x, 64, palpha, depth_multiplier, block_id=1)

    x = _depthwise_conv_block_mod(x,
                                  128,
                                  palpha,
                                  depth_multiplier,
                                  strides=(2, 2),
                                  block_id=2)
    x = _depthwise_conv_block_mod(x, 128, palpha, depth_multiplier, block_id=3)

    x = _depthwise_conv_block_mod(x,
                                  256,
                                  palpha,
                                  depth_multiplier,
                                  strides=(2, 2),
                                  block_id=4)
    x = _depthwise_conv_block_mod(x, 256, palpha, depth_multiplier, block_id=5)

    # x = _depthwise_conv_block_mod(x, 512, palpha, depth_multiplier, strides=(2, 2), block_id=6)
    x = _depthwise_conv_block_mod(x,
                                  512,
                                  palpha,
                                  depth_multiplier,
                                  strides=(1, 1),
                                  block_id=6)
    x = _depthwise_conv_block_mod(x, 512, palpha, depth_multiplier, block_id=7)
    x = _depthwise_conv_block_mod(x, 512, palpha, depth_multiplier, block_id=8)
    x = _depthwise_conv_block_mod(x, 512, palpha, depth_multiplier, block_id=9)
    x = _depthwise_conv_block_mod(x,
                                  512,
                                  palpha,
                                  depth_multiplier,
                                  block_id=10)
    # x = _depthwise_conv_block_mod(x, 512, palpha, depth_multiplier, block_id=11)

    # x = _depthwise_conv_block_mod(x, 1024, palpha, depth_multiplier, strides=(2, 2), block_id=12)
    # x = _depthwise_conv_block_mod(x, 1024, palpha, depth_multiplier, block_id=13)
    return x