當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。