def create_homographynet_mobilenet_v2(weights_file=None, input_shape=(128, 128, 2), num_pts=4, alpha=1.0, pooling=None, **kwargs): """ Use fully convolutional structure to support any input shape """ base_model = mobilenet_v2.MobileNetV2(input_shape=input_shape, include_top=False, weights=None, alpha=alpha) # The output shape just before the pooling and dense layers is: (4, 4, 1024) x = base_model.output if pooling == 'max': x = GlobalMaxPool2D(name='global_max_pool2d')(x) # to support any input shape elif pooling == 'avg': x = GlobalAveragePooling2D(name='global_avg_pool2d')(x) # to support any input shape else: x = Flatten(name='flatten')(x) x = Dropout(rate=0.5, name='dropout')(x) x = Dense(2*num_pts, name='preds')(x) model = Model(inputs=base_model.input, outputs=x, name='homographynet_mobilenet_v2') if weights_file is not None: model.load_weights(weights_file) return model
def MobileNetV2(*args, **kwargs): return mobilenet_v2.MobileNetV2(*args, **kwargs)