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


Python vgg19.preprocess_input方法代码示例

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


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

示例1: extra_feat

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def extra_feat(img_path):
        #Using a VGG19 as feature extractor
        base_model = VGG19(weights='imagenet',include_top=False)
	img = image.load_img(img_path, target_size=(224, 224))
	x = image.img_to_array(img)
	x = np.expand_dims(x, axis=0)
	x = preprocess_input(x)
        block1_pool_features=get_activations(base_model, 3, x)
        block2_pool_features=get_activations(base_model, 6, x)
        block3_pool_features=get_activations(base_model, 10, x)
        block4_pool_features=get_activations(base_model, 14, x)
        block5_pool_features=get_activations(base_model, 18, x)

	x1 = tf.image.resize_images(block1_pool_features[0],[112,112])
	x2 = tf.image.resize_images(block2_pool_features[0],[112,112])
	x3 = tf.image.resize_images(block3_pool_features[0],[112,112])
	x4 = tf.image.resize_images(block4_pool_features[0],[112,112])
	x5 = tf.image.resize_images(block5_pool_features[0],[112,112])
	
	F = tf.concat([x3,x2,x1,x4,x5],3) #Change to only x1, x1+x2,x1+x2+x3..so on, inorder to visualize features from diffetrrnt blocks
        return F 
开发者ID:vbhavank,项目名称:Unstructured-change-detection-using-CNN,代码行数:23,代码来源:feat.py

示例2: preprocess_image

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def preprocess_image(image_path):
    img = load_img(image_path, target_size=(img_height, img_width))
    img = img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = vgg19.preprocess_input(img)
    return img 
开发者ID:wdxtub,项目名称:deep-learning-note,代码行数:8,代码来源:3_nerual_style_transfer.py

示例3: preprocess_image

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def preprocess_image(image_path):
    img = image.load_img(image_path, target_size=(224, 224))
    img = image.img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = preprocess_input(img)
    return img 
开发者ID:nladuo,项目名称:MMFinder,代码行数:8,代码来源:feature_extraction.py

示例4: extract_VGG16

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

示例5: extract_VGG19

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

示例6: extract_Resnet50

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

示例7: extract_Xception

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [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

示例8: extract_InceptionV3

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

示例9: call

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def call(self, x, y):
        x = ((x + 1) / 2) * 255.0
        y = ((y + 1) / 2) * 255.0
        x_vgg, y_vgg = self.vgg(preprocess_input(x)), self.vgg(preprocess_input(y))

        loss = 0

        for i in range(len(x_vgg)):
            y_vgg_detach = tf.stop_gradient(y_vgg[i])
            loss += self.layer_weights[i] * L1_loss(x_vgg[i], y_vgg_detach)

        return loss 
开发者ID:taki0112,项目名称:SPADE-Tensorflow,代码行数:14,代码来源:vgg19_keras.py

示例10: extract

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def extract(path):
    im = cv2.imread(path)
    #img = image.load_img(path, target_size=(448,448))
    if im is None:
        raise Exception("Incorrect path")
    #im = cv2.resize(im, (448, 448))
    #im = im.transpose((2,0,1))
    #im = np.expand_dims(im, axis=0)
    im = cv2.resize(im, (448,448)).astype(np.float32)
    im = im * 255
    im[:,:,0] -= 103.939
    im[:,:,1] -= 116.779
    im[:,:,2] -= 123.68
    #im = im.transpose((2,0,1))
    im = np.expand_dims(im, axis=0)
    #x = image.img_to_array(img)
    #x = np.expand_dims(x, axis=0)
    #x = preprocess_input(x)
    im = preprocess_input(im)
#    print (im.shape)
    # Test pretrained model
    model = get_model()
    sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
    model.compile(optimizer=sgd, loss='categorical_crossentropy')
    out = model.predict(im)
    
    return out 
开发者ID:channelCS,项目名称:Audio-Vision,代码行数:29,代码来源:extract_features.py

示例11: preprocess_image

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def preprocess_image(image_path):
    img = load_img(image_path, target_size=(img_nrows, img_ncols))
    img = img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = vgg19.preprocess_input(img)
    return img

# util function to convert a tensor into a valid image 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:10,代码来源:neural_style_transfer.py

示例12: preprocess_image

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def preprocess_image(image_path):
    img = load_img(image_path, target_size=(img_nrows, img_ncols))
    img = img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = vgg19.preprocess_input(img)
    return img 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:8,代码来源:neural_doodle.py

示例13: preprocess_image

# 需要导入模块: from keras.applications import vgg19 [as 别名]
# 或者: from keras.applications.vgg19 import preprocess_input [as 别名]
def preprocess_image(image):
    """
    预处理图片,包括变形到(1,width, height)形状,数据归一到0-1之间
    :param image: 输入一张图片
    :return: 预处理好的图片
    """
    image = image.resize((width, height))
    image = img_to_array(image)
    image = np.expand_dims(image, axis=0)  # (width, height)->(1,width, height)
    image = vgg19.preprocess_input(image)  # 0-255 -> 0-1.0
    return image 
开发者ID:yuweiming70,项目名称:Style_Migration_For_Artistic_Font_With_CNN,代码行数:13,代码来源:neural_style_transfer.py


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