Tensorflow 从ImageDataGenerator选择imagenet_utils.preprocess_输入模式的可能性
有一种预处理技术,我们可以使用以下方法针对ImageNet数据集预处理图像:Tensorflow 从ImageDataGenerator选择imagenet_utils.preprocess_输入模式的可能性,tensorflow,image-processing,keras,conv-neural-network,Tensorflow,Image Processing,Keras,Conv Neural Network,有一种预处理技术,我们可以使用以下方法针对ImageNet数据集预处理图像: from keras.applications import imagenet_utils imagenet_utils.preprocess_input(image, mode='caffe') 你看,我选择了mode='caffe'。事实上,Keras.applicationsAPI解释了三种模式: mode: One of "caffe", "tf" or "t
from keras.applications import imagenet_utils
imagenet_utils.preprocess_input(image, mode='caffe')
你看,我选择了mode='caffe'
。事实上,Keras.applications
API解释了三种模式:
mode: One of "caffe", "tf" or "torch".
- caffe: will convert the images from RGB to BGR,
then will zero-center each color channel with
respect to the ImageNet dataset,
without scaling.
- tf: will scale pixels between -1 and 1,
sample-wise.
- torch: will scale pixels between 0 and 1 and then
will normalize each channel with respect to the
ImageNet dataset.
由于我在代码中使用了keras.preprocessing.image
中的ImageDataGenerator
,是否有一种变通方法,允许从ImageDataGenerator
中设置此类模式,因为这三种模式适用于ImageNet数据集
谢谢ImageDataGenerator有一个
预处理函数
参数,您可以在其中传递一个要应用于图像的函数。要调整模式,可以执行以下操作:
from keras.applications import imagenet_utils
imagenet_utils.preprocess_input(image, mode='caffe')
从functools导入部分
从keras.applications导入imagenet_utils
imagenet\u caffe\u preprocessing\u函数=部分(imagenet\u utils.preprocess\u输入,mode=“caffe”)
数据\u生成器=图像数据生成器(预处理\u函数=图像网络\u caffe\u预处理\u函数,…)