def MobileNet(input_shape=None, alpha=1.0, depth_multiplier=1, dropout=0.001, include_top=True, weights='imagenet', input_tensor=None, pooling=None, classes=1000):
    "Instantiates the MobileNet architecture.\n\n  Note that only TensorFlow is supported for now,\n  therefore it only works with the data format\n  `image_data_format='channels_last'` in your Keras config\n  at `~/.keras/keras.json`.\n\n  To load a MobileNet model via `load_model`, import the custom\n  objects `relu6` and `DepthwiseConv2D` and pass them to the\n  `custom_objects` parameter.\n  E.g.\n  model = load_model('mobilenet.h5', custom_objects={\n                     'relu6': mobilenet.relu6,\n                     'DepthwiseConv2D': mobilenet.DepthwiseConv2D})\n\n  Arguments:\n      input_shape: optional shape tuple, only to be specified\n          if `include_top` is False (otherwise the input shape\n          has to be `(224, 224, 3)` (with `channels_last` data format)\n          or (3, 224, 224) (with `channels_first` data format).\n          It should have exactly 3 inputs channels,\n          and width and height should be no smaller than 32.\n          E.g. `(200, 200, 3)` would be one valid value.\n      alpha: controls the width of the network.\n          - If `alpha` < 1.0, proportionally decreases the number\n              of filters in each layer.\n          - If `alpha` > 1.0, proportionally increases the number\n              of filters in each layer.\n          - If `alpha` = 1, default number of filters from the paper\n               are used at each layer.\n      depth_multiplier: depth multiplier for depthwise convolution\n          (also called the resolution multiplier)\n      dropout: dropout rate\n      include_top: whether to include the fully-connected\n          layer at the top of the network.\n      weights: one of `None` (random initialization),\n            'imagenet' (pre-training on ImageNet),\n            or the path to the weights file to be loaded.\n      input_tensor: optional Keras tensor (i.e. output of\n          `layers.Input()`)\n          to use as image input for the model.\n      pooling: Optional pooling mode for feature extraction\n          when `include_top` is `False`.\n          - `None` means that the output of the model\n              will be the 4D tensor output of the\n              last convolutional layer.\n          - `avg` means that global average pooling\n              will be applied to the output of the\n              last convolutional layer, and thus\n              the output of the model will be a\n              2D tensor.\n          - `max` means that global max pooling will\n              be applied.\n      classes: optional number of classes to classify images\n          into, only to be specified if `include_top` is True, and\n          if no `weights` argument is specified.\n\n  Returns:\n      A Keras model instance.\n\n  Raises:\n      ValueError: in case of invalid argument for `weights`,\n          or invalid input shape.\n      RuntimeError: If attempting to run this model with a\n          backend that does not support separable convolutions.\n  "
    if (K.backend() != 'tensorflow'):
        raise RuntimeError('Only TensorFlow backend is currently supported, as other backends do not support depthwise convolution.')
    if (not ((weights in {'imagenet', None}) or os.path.exists(weights))):
        raise ValueError('The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.')
    if ((weights == 'imagenet') and include_top and (classes != 1000)):
        raise ValueError('If using `weights` as ImageNet with `include_top` as true, `classes` should be 1000')
    if (input_shape is None):
        default_size = 224
    else:
        if (K.image_data_format() == 'channels_first'):
            rows = input_shape[1]
            cols = input_shape[2]
        else:
            rows = input_shape[0]
            cols = input_shape[1]
        if ((rows == cols) and (rows in [128, 160, 192, 224])):
            default_size = rows
        else:
            default_size = 224
    input_shape = _obtain_input_shape(input_shape, default_size=default_size, min_size=32, data_format=K.image_data_format(), require_flatten=include_top, weights=weights)
    if (K.image_data_format() == 'channels_last'):
        (row_axis, col_axis) = (0, 1)
    else:
        (row_axis, col_axis) = (1, 2)
    rows = input_shape[row_axis]
    cols = input_shape[col_axis]
    if (weights == 'imagenet'):
        if (depth_multiplier != 1):
            raise ValueError('If imagenet weights are being loaded, depth multiplier must be 1')
        if (alpha not in [0.25, 0.5, 0.75, 1.0]):
            raise ValueError('If imagenet weights are being loaded, alpha can be one of`0.25`, `0.50`, `0.75` or `1.0` only.')
        if ((rows != cols) or (rows not in [128, 160, 192, 224])):
            raise ValueError(('If imagenet weights are being loaded, input must have a static square shape (one of (128,128), (160,160), (192,192), or (224, 224)). Input shape provided = %s' % (input_shape,)))
    if (K.image_data_format() != 'channels_last'):
        logging.warning('The MobileNet family of models is only available for the input data format "channels_last" (width, height, channels). However your settings specify the default data format "channels_first" (channels, width, height). You should set `image_data_format="channels_last"` in your Keras config located at ~/.keras/keras.json. The model being returned right now will expect inputs to follow the "channels_last" data format.')
        K.set_image_data_format('channels_last')
        old_data_format = 'channels_first'
    else:
        old_data_format = None
    if (input_tensor is None):
        img_input = Input(shape=input_shape)
    elif (not K.is_keras_tensor(input_tensor)):
        img_input = Input(tensor=input_tensor, shape=input_shape)
    else:
        img_input = input_tensor
    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)
    if include_top:
        if (K.image_data_format() == 'channels_first'):
            shape = (int((1024 * alpha)), 1, 1)
        else:
            shape = (1, 1, int((1024 * alpha)))
        x = GlobalAveragePooling2D()(x)
        x = Reshape(shape, name='reshape_1')(x)
        x = Dropout(dropout, name='dropout')(x)
        x = Conv2D(classes, (1, 1), padding='same', name='conv_preds')(x)
        x = Activation('softmax', name='act_softmax')(x)
        x = Reshape((classes,), name='reshape_2')(x)
    elif (pooling == 'avg'):
        x = GlobalAveragePooling2D()(x)
    elif (pooling == 'max'):
        x = GlobalMaxPooling2D()(x)
    if (input_tensor is not None):
        inputs = get_source_inputs(input_tensor)
    else:
        inputs = img_input
    model = Model(inputs, x, name=('mobilenet_%0.2f_%s' % (alpha, rows)))
    if (weights == 'imagenet'):
        if (K.image_data_format() == 'channels_first'):
            raise ValueError('Weights for "channels_last" format are not available.')
        if (alpha == 1.0):
            alpha_text = '1_0'
        elif (alpha == 0.75):
            alpha_text = '7_5'
        elif (alpha == 0.5):
            alpha_text = '5_0'
        else:
            alpha_text = '2_5'
        if include_top:
            model_name = ('mobilenet_%s_%d_tf.h5' % (alpha_text, rows))
            weigh_path = (BASE_WEIGHT_PATH + model_name)
            weights_path = get_file(model_name, weigh_path, cache_subdir='models')
        else:
            model_name = ('mobilenet_%s_%d_tf_no_top.h5' % (alpha_text, rows))
            weigh_path = (BASE_WEIGHT_PATH + model_name)
            weights_path = get_file(model_name, weigh_path, cache_subdir='models')
        model.load_weights(weights_path)
    elif (weights is not None):
        model.load_weights(weights)
    if old_data_format:
        K.set_image_data_format(old_data_format)
    return model
Instantiates the MobileNet architecture.

Note that only TensorFlow is supported for now,
therefore it only works with the data format
`image_data_format='channels_last'` in your Keras config
at `~/.keras/keras.json`.

To load a MobileNet model via `load_model`, import the custom
objects `relu6` and `DepthwiseConv2D` and pass them to the
`custom_objects` parameter.
E.g.
model = load_model('mobilenet.h5', custom_objects={
                   'relu6': mobilenet.relu6,
                   'DepthwiseConv2D': mobilenet.DepthwiseConv2D})

Arguments:
    input_shape: optional shape tuple, only to be specified
        if `include_top` is False (otherwise the input shape
        has to be `(224, 224, 3)` (with `channels_last` data format)
        or (3, 224, 224) (with `channels_first` data format).
        It should have exactly 3 inputs channels,
        and width and height should be no smaller than 32.
        E.g. `(200, 200, 3)` would be one valid value.
    alpha: controls the width of the network.
        - If `alpha` < 1.0, proportionally decreases the number
            of filters in each layer.
        - If `alpha` > 1.0, proportionally increases the number
            of filters in each layer.
        - If `alpha` = 1, default number of filters from the paper
             are used at each layer.
    depth_multiplier: depth multiplier for depthwise convolution
        (also called the resolution multiplier)
    dropout: dropout rate
    include_top: whether to include the fully-connected
        layer at the top of the network.
    weights: one of `None` (random initialization),
          'imagenet' (pre-training on ImageNet),
          or the path to the weights file to be loaded.
    input_tensor: optional Keras tensor (i.e. output of
        `layers.Input()`)
        to use as image input for the model.
    pooling: Optional pooling mode for feature extraction
        when `include_top` is `False`.
        - `None` means that the output of the model
            will be the 4D tensor output of the
            last convolutional layer.
        - `avg` means that global average pooling
            will be applied to the output of the
            last convolutional layer, and thus
            the output of the model will be a
            2D tensor.
        - `max` means that global max pooling will
            be applied.
    classes: optional number of classes to classify images
        into, only to be specified if `include_top` is True, and
        if no `weights` argument is specified.

Returns:
    A Keras model instance.

Raises:
    ValueError: in case of invalid argument for `weights`,
        or invalid input shape.
    RuntimeError: If attempting to run this model with a
        backend that does not support separable convolutions.
def MobileNet(input_shape=None, alpha=1.0, depth_multiplier=1, dropout=0.001, include_top=True, weights='imagenet', input_tensor=None, pooling=None, classes=1000):
    "Instantiates the MobileNet architecture.\n\n  Note that only TensorFlow is supported for now,\n  therefore it only works with the data format\n  `image_data_format='channels_last'` in your Keras config\n  at `~/.keras/keras.json`.\n\n  To load a MobileNet model via `load_model`, import the custom\n  objects `relu6` and `DepthwiseConv2D` and pass them to the\n  `custom_objects` parameter.\n  E.g.\n  model = load_model('mobilenet.h5', custom_objects={\n                     'relu6': mobilenet.relu6,\n                     'DepthwiseConv2D': mobilenet.DepthwiseConv2D})\n\n  Arguments:\n      input_shape: optional shape tuple, only to be specified\n          if `include_top` is False (otherwise the input shape\n          has to be `(224, 224, 3)` (with `channels_last` data format)\n          or (3, 224, 224) (with `channels_first` data format).\n          It should have exactly 3 inputs channels,\n          and width and height should be no smaller than 32.\n          E.g. `(200, 200, 3)` would be one valid value.\n      alpha: controls the width of the network.\n          - If `alpha` < 1.0, proportionally decreases the number\n              of filters in each layer.\n          - If `alpha` > 1.0, proportionally increases the number\n              of filters in each layer.\n          - If `alpha` = 1, default number of filters from the paper\n               are used at each layer.\n      depth_multiplier: depth multiplier for depthwise convolution\n          (also called the resolution multiplier)\n      dropout: dropout rate\n      include_top: whether to include the fully-connected\n          layer at the top of the network.\n      weights: one of `None` (random initialization),\n            'imagenet' (pre-training on ImageNet),\n            or the path to the weights file to be loaded.\n      input_tensor: optional Keras tensor (i.e. output of\n          `layers.Input()`)\n          to use as image input for the model.\n      pooling: Optional pooling mode for feature extraction\n          when `include_top` is `False`.\n          - `None` means that the output of the model\n              will be the 4D tensor output of the\n              last convolutional layer.\n          - `avg` means that global average pooling\n              will be applied to the output of the\n              last convolutional layer, and thus\n              the output of the model will be a\n              2D tensor.\n          - `max` means that global max pooling will\n              be applied.\n      classes: optional number of classes to classify images\n          into, only to be specified if `include_top` is True, and\n          if no `weights` argument is specified.\n\n  Returns:\n      A Keras model instance.\n\n  Raises:\n      ValueError: in case of invalid argument for `weights`,\n          or invalid input shape.\n      RuntimeError: If attempting to run this model with a\n          backend that does not support separable convolutions.\n  "
    if (K.backend() != 'tensorflow'):
        raise RuntimeError('Only TensorFlow backend is currently supported, as other backends do not support depthwise convolution.')
    if (not ((weights in {'imagenet', None}) or os.path.exists(weights))):
        raise ValueError('The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.')
    if ((weights == 'imagenet') and include_top and (classes != 1000)):
        raise ValueError('If using `weights` as ImageNet with `include_top` as true, `classes` should be 1000')
    if (input_shape is None):
        default_size = 224
    else:
        if (K.image_data_format() == 'channels_first'):
            rows = input_shape[1]
            cols = input_shape[2]
        else:
            rows = input_shape[0]
            cols = input_shape[1]
        if ((rows == cols) and (rows in [128, 160, 192, 224])):
            default_size = rows
        else:
            default_size = 224
    input_shape = _obtain_input_shape(input_shape, default_size=default_size, min_size=32, data_format=K.image_data_format(), require_flatten=include_top, weights=weights)
    if (K.image_data_format() == 'channels_last'):
        (row_axis, col_axis) = (0, 1)
    else:
        (row_axis, col_axis) = (1, 2)
    rows = input_shape[row_axis]
    cols = input_shape[col_axis]
    if (weights == 'imagenet'):
        if (depth_multiplier != 1):
            raise ValueError('If imagenet weights are being loaded, depth multiplier must be 1')
        if (alpha not in [0.25, 0.5, 0.75, 1.0]):
            raise ValueError('If imagenet weights are being loaded, alpha can be one of`0.25`, `0.50`, `0.75` or `1.0` only.')
        if ((rows != cols) or (rows not in [128, 160, 192, 224])):
            raise ValueError(('If imagenet weights are being loaded, input must have a static square shape (one of (128,128), (160,160), (192,192), or (224, 224)). Input shape provided = %s' % (input_shape,)))
    if (K.image_data_format() != 'channels_last'):
        logging.warning('The MobileNet family of models is only available for the input data format "channels_last" (width, height, channels). However your settings specify the default data format "channels_first" (channels, width, height). You should set `image_data_format="channels_last"` in your Keras config located at ~/.keras/keras.json. The model being returned right now will expect inputs to follow the "channels_last" data format.')
        K.set_image_data_format('channels_last')
        old_data_format = 'channels_first'
    else:
        old_data_format = None
    if (input_tensor is None):
        img_input = Input(shape=input_shape)
    elif (not K.is_keras_tensor(input_tensor)):
        img_input = Input(tensor=input_tensor, shape=input_shape)
    else:
        img_input = input_tensor
    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)
    if include_top:
        if (K.image_data_format() == 'channels_first'):
            shape = (int((1024 * alpha)), 1, 1)
        else:
            shape = (1, 1, int((1024 * alpha)))
        x = GlobalAveragePooling2D()(x)
        x = Reshape(shape, name='reshape_1')(x)
        x = Dropout(dropout, name='dropout')(x)
        x = Conv2D(classes, (1, 1), padding='same', name='conv_preds')(x)
        x = Activation('softmax', name='act_softmax')(x)
        x = Reshape((classes,), name='reshape_2')(x)
    elif (pooling == 'avg'):
        x = GlobalAveragePooling2D()(x)
    elif (pooling == 'max'):
        x = GlobalMaxPooling2D()(x)
    if (input_tensor is not None):
        inputs = get_source_inputs(input_tensor)
    else:
        inputs = img_input
    model = Model(inputs, x, name=('mobilenet_%0.2f_%s' % (alpha, rows)))
    if (weights == 'imagenet'):
        if (K.image_data_format() == 'channels_first'):
            raise ValueError('Weights for "channels_last" format are not available.')
        if (alpha == 1.0):
            alpha_text = '1_0'
        elif (alpha == 0.75):
            alpha_text = '7_5'
        elif (alpha == 0.5):
            alpha_text = '5_0'
        else:
            alpha_text = '2_5'
        if include_top:
            model_name = ('mobilenet_%s_%d_tf.h5' % (alpha_text, rows))
            weigh_path = (BASE_WEIGHT_PATH + model_name)
            weights_path = get_file(model_name, weigh_path, cache_subdir='models')
        else:
            model_name = ('mobilenet_%s_%d_tf_no_top.h5' % (alpha_text, rows))
            weigh_path = (BASE_WEIGHT_PATH + model_name)
            weights_path = get_file(model_name, weigh_path, cache_subdir='models')
        model.load_weights(weights_path)
    elif (weights is not None):
        model.load_weights(weights)
    if old_data_format:
        K.set_image_data_format(old_data_format)
    return model