当前位置: 首页>>代码示例>>Python>>正文


Python xception.Xception方法代码示例

本文整理汇总了Python中keras.applications.xception.Xception方法的典型用法代码示例。如果您正苦于以下问题:Python xception.Xception方法的具体用法?Python xception.Xception怎么用?Python xception.Xception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras.applications.xception的用法示例。


在下文中一共展示了xception.Xception方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _imagenet_preprocess_input

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def _imagenet_preprocess_input(x, input_shape):
    """
    For ResNet50, VGG models. For InceptionV3 and Xception it's okay to use the
    keras version (e.g. InceptionV3.preprocess_input) as the code path they hit
    works okay with tf.Tensor inputs. The following was translated to tf ops from
    https://github.com/fchollet/keras/blob/fb4a0849cf4dc2965af86510f02ec46abab1a6a4/keras/applications/imagenet_utils.py#L52
    It's a possibility to change the implementation in keras to look like the
    following and modified to work with BGR images (standard in Spark), but not doing it for now.
    """
    # assuming 'BGR'
    # Zero-center by mean pixel
    mean = np.ones(input_shape + (3,), dtype=np.float32)
    mean[..., 0] = 103.939
    mean[..., 1] = 116.779
    mean[..., 2] = 123.68
    return x - mean 
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:18,代码来源:keras_applications.py

示例2: get_model

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def get_model(session):

    # create the base pre-trained model
    base_model = Xception(weights=None, include_top=False, input_shape=(270, 480, 3))

    # add a global spatial average pooling layer
    x = base_model.output
    x = GlobalAveragePooling2D()(x)
    # add a fully-connected layer
    x = Dense(1024, activation='relu')(x)
    # putput layer
    predictions = Dense(session.training_dataset_info['number_of_labels'], activation='softmax')(x)
    # model
    model = Model(inputs=base_model.input, outputs=predictions)

    learning_rate = 0.001
    opt = keras.optimizers.adam(lr=learning_rate, decay=1e-5)

    model.compile(loss='categorical_crossentropy',
                  optimizer=opt,
                  metrics=['accuracy'])

    return model 
开发者ID:Sentdex,项目名称:pygta5,代码行数:25,代码来源:xception.py

示例3: _get_base_model

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def _get_base_model(self):
        """
        :return: base model from Keras based on user-supplied model name
        """
        if self.model_name == 'inception_v3':
            return InceptionV3(weights='imagenet', include_top=False)
        elif self.model_name == 'xception':
            return Xception(weights='imagenet', include_top=False)
        elif self.model_name == 'vgg16':
            return VGG16(weights='imagenet', include_top=False)
        elif self.model_name == 'vgg19':
            return VGG19(weights='imagenet', include_top=False)
        elif self.model_name == 'resnet50':
            return ResNet50(weights='imagenet', include_top=False)
        else:
            raise ValueError('Cannot find base model %s' % self.model_name) 
开发者ID:thoughtworksarts,项目名称:EmoPy,代码行数:18,代码来源:neuralnets.py

示例4: model

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def model(self, preprocessed, featurize):
        # Model provided by Keras. All cotributions by Keras are provided subject to the
        # MIT license located at https://github.com/fchollet/keras/blob/master/LICENSE.
        return xception.Xception(input_tensor=preprocessed, weights="imagenet",
                                 include_top=(not featurize)) 
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:7,代码来源:keras_applications.py

示例5: _testKerasModel

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def _testKerasModel(self, include_top):
        return xception.Xception(weights="imagenet",
                                 include_top=include_top) 
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:5,代码来源:keras_applications.py

示例6: extract_Xception

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def extract_Xception(tensor):
	from keras.applications.xception import Xception, preprocess_input
	return Xception(weights='imagenet', include_top=False).predict(preprocess_input(tensor)) 
开发者ID:kubeflow-kale,项目名称:kale,代码行数:5,代码来源:extract_bottleneck_features.py

示例7: get_xception_model

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def get_xception_model(img_dim):
    array_input = Input(shape=(img_dim, img_dim, 3))
    xception = Xception(include_top=True,
                     weights='imagenet',
                     input_tensor=array_input,
                     pooling='avg')
    return xception 
开发者ID:matthew-sochor-zz,项目名称:transfer,代码行数:9,代码来源:xception.py

示例8: test_Xception

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def test_Xception(self):
        from keras.applications.xception import Xception
        model = Xception(include_top=True, weights='imagenet')
        res = run_image(model, self.model_files, img_path, atol=5e-3, target_size=299)
        self.assertTrue(*res) 
开发者ID:onnx,项目名称:keras-onnx,代码行数:7,代码来源:test_keras_applications.py

示例9: create_model

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def create_model(input_shape, config):

    input_tensor = Input(shape=input_shape)  # this assumes K.image_dim_ordering() == 'tf'
    xception_model = Xception(include_top=False, weights=None, input_tensor=input_tensor)
    print(xception_model.summary())

    x = xception_model.output
    x = GlobalAveragePooling2D()(x)
    predictions = Dense(config["num_classes"], activation='softmax')(x)

    return Model(input=xception_model.input, output=predictions) 
开发者ID:HPI-DeepLearning,项目名称:crnn-lid,代码行数:13,代码来源:xception.py

示例10: model_base_Xception

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def model_base_Xception(input_shape):
    model = Xception(weights=None, include_top=False, input_shape=input_shape)

    # Grab last model layer and attach global average pooling layer
    x = model.output
    x = GlobalAveragePooling2D()(x)

    return model.input, x

# First small CNN model 
开发者ID:Sentdex,项目名称:Carla-RL,代码行数:12,代码来源:models.py

示例11: get_tst_neural_net

# 需要导入模块: from keras.applications import xception [as 别名]
# 或者: from keras.applications.xception import Xception [as 别名]
def get_tst_neural_net(type):
    model = None
    custom_objects = dict()
    if type == 'mobilenet_small':
        from keras.applications.mobilenet import MobileNet
        model = MobileNet((128, 128, 3), depth_multiplier=1, alpha=0.25, include_top=True, weights='imagenet')
    elif type == 'mobilenet':
        from keras.applications.mobilenet import MobileNet
        model = MobileNet((224, 224, 3), depth_multiplier=1, alpha=1.0, include_top=True, weights='imagenet')
    elif type == 'mobilenet_v2':
        from keras.applications.mobilenetv2 import MobileNetV2
        model = MobileNetV2((224, 224, 3), depth_multiplier=1, alpha=1.4, include_top=True, weights='imagenet')
    elif type == 'resnet50':
        from keras.applications.resnet50 import ResNet50
        model = ResNet50(input_shape=(224, 224, 3), include_top=True, weights='imagenet')
    elif type == 'inception_v3':
        from keras.applications.inception_v3 import InceptionV3
        model = InceptionV3(input_shape=(299, 299, 3), include_top=True, weights='imagenet')
    elif type == 'inception_resnet_v2':
        from keras.applications.inception_resnet_v2 import InceptionResNetV2
        model = InceptionResNetV2(input_shape=(299, 299, 3), include_top=True, weights='imagenet')
    elif type == 'xception':
        from keras.applications.xception import Xception
        model = Xception(input_shape=(299, 299, 3), include_top=True, weights='imagenet')
    elif type == 'densenet121':
        from keras.applications.densenet import DenseNet121
        model = DenseNet121(input_shape=(224, 224, 3), include_top=True, weights='imagenet')
    elif type == 'densenet169':
        from keras.applications.densenet import DenseNet169
        model = DenseNet169(input_shape=(224, 224, 3), include_top=True, weights='imagenet')
    elif type == 'densenet201':
        from keras.applications.densenet import DenseNet201
        model = DenseNet201(input_shape=(224, 224, 3), include_top=True, weights='imagenet')
    elif type == 'nasnetmobile':
        from keras.applications.nasnet import NASNetMobile
        model = NASNetMobile(input_shape=(224, 224, 3), include_top=True, weights='imagenet')
    elif type == 'nasnetlarge':
        from keras.applications.nasnet import NASNetLarge
        model = NASNetLarge(input_shape=(331, 331, 3), include_top=True, weights='imagenet')
    elif type == 'vgg16':
        from keras.applications.vgg16 import VGG16
        model = VGG16(input_shape=(224, 224, 3), include_top=False, pooling='avg', weights='imagenet')
    elif type == 'vgg19':
        from keras.applications.vgg19 import VGG19
        model = VGG19(input_shape=(224, 224, 3), include_top=False, pooling='avg', weights='imagenet')
    elif type == 'multi_io':
        model = get_custom_multi_io_model()
    elif type == 'multi_model_layer_1':
        model = get_custom_model_with_other_model_as_layer()
    elif type == 'multi_model_layer_2':
        model = get_small_model_with_other_model_as_layer()
    elif type == 'Conv2DTranspose':
        model = get_Conv2DTranspose_model()
    elif type == 'RetinaNet':
        model, custom_objects = get_RetinaNet_model()
    elif type == 'conv3d_model':
        model = get_simple_3d_model()
    return model, custom_objects 
开发者ID:ZFTurbo,项目名称:Keras-inference-time-optimizer,代码行数:60,代码来源:test_bench.py


注:本文中的keras.applications.xception.Xception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。