Пример #1
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
Пример #2
0
def create_mobile_net_model(size, alpha):
    model_net = MobileNet(input_shape=(size, size, 3),
                          include_top=False,
                          alpha=alpha)
    x = _depthwise_conv_block(model_net.layers[-1].output,
                              1024,
                              alpha,
                              1,
                              block_id=14)
    x = Conv2D(64, (3, 3), activation='relu')(x)
    x = MaxPooling2D(pool_size=(4, 4))(x)
    x = Conv2D(8, kernel_size=(1, 1), padding="same")(x)
    x = Reshape((8, ))(x)
    return Model(inputs=model_net.input, outputs=x)
Пример #3
0
def create_model(size, alpha):

    model_net = MobileNet(input_shape=(size, size, 3),
                          include_top=False,
                          weights="imagenet",
                          alpha=alpha)
    # for i in range(len(model_net.layers) - 13):
    #    model_net.layers[i].trainable=False
    x = _depthwise_conv_block(model_net.layers[-1].output,
                              1024 / 4,
                              alpha,
                              1,
                              block_id=14)
    x = MaxPooling2D(pool_size=(3, 3))(x)
    x = Conv2D(4, kernel_size=(1, 1), padding="same")(x)
    x = Reshape((4, ))(x)

    return Model(inputs=model_net.input, outputs=x)
Пример #4
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