Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 关于Keras imagedatagenerator.flow(图像,目标)中的目标发生了什么的问题_Tensorflow_Machine Learning_Keras - Fatal编程技术网

Tensorflow 关于Keras imagedatagenerator.flow(图像,目标)中的目标发生了什么的问题

Tensorflow 关于Keras imagedatagenerator.flow(图像,目标)中的目标发生了什么的问题,tensorflow,machine-learning,keras,Tensorflow,Machine Learning,Keras,我的图像有前景和背景,我的目标是图像的像素分类(0和1)。我想使用ImageDataGenerator剪切/缩放/翻转这些图像-目标对,以便获得更多的训练数据。如果我使用imagedatagenerator.flow(图像,目标),我的目标是否会以与图像相同的方式被剪切/放大?如果samplewise center为真,目标值是否也会居中?谢谢大家! tf.keras.preprocessing.image.ImageDataGenerator用于根据目标图像的指定规格从给定图像生成图像。示例:

我的图像有前景和背景,我的目标是图像的像素分类(0和1)。我想使用ImageDataGenerator剪切/缩放/翻转这些图像-目标对,以便获得更多的训练数据。如果我使用imagedatagenerator.flow(图像,目标),我的目标是否会以与图像相同的方式被剪切/放大?如果samplewise center为真,目标值是否也会居中?谢谢大家!

tf.keras.preprocessing.image.ImageDataGenerator
用于根据目标图像的指定规格从给定图像生成图像。示例:您可以执行翻转/剪切/缩放/更改高度/宽度以获取图像

获取目标映像的规范,并将其提供给ImageDataGenerator库以生成所需类型的映像

下面的示例代码可能对您有所帮助

import tensorflow as tf
image = tf.keras.preprocessing.image.load_img('2.jpeg')
datagen = tf.keras.preprocessing.image.ImageDataGenerator(rotation_range=40,
                                                          width_shift_range=0.2,
                                                          height_shift_range=0.2,
                                                          rescale=1./255,
                                                          shear_range=0.2,
                                                          zoom_range=0.2,
                                                          horizontal_flip=True,
                                                          fill_mode='nearest')
image.getpixel
image_array = tf.keras.preprocessing.image.img_to_array(image)
image_array = image_array.reshape((1,) + image_array.shape)
count = 0
for batch in datagen.flow(image_new, batch_size=1, save_to_dir ='images_gen' , save_prefix='cat', save_format='jpeg'):
  count +=1
  if count==10:
    break
#显示输入图像

import matplotlib.pylab as plt
image = plt.imread('2.jpeg')
plt.imshow(image)
plt.show()

#在ImageDataGenerator之后显示图像

import matplotlib.pylab as plt
image = plt.imread('images_gen/cat_0_2229.jpeg')
plt.imshow(image)
plt.show()

tf.keras.preprocessing.image.ImageDataGenerator
用于根据指定的目标图像规格从给定图像生成图像。示例:您可以执行翻转/剪切/缩放/更改高度/宽度以获取图像

获取目标映像的规范,并将其提供给ImageDataGenerator库以生成所需类型的映像

下面的示例代码可能对您有所帮助

import tensorflow as tf
image = tf.keras.preprocessing.image.load_img('2.jpeg')
datagen = tf.keras.preprocessing.image.ImageDataGenerator(rotation_range=40,
                                                          width_shift_range=0.2,
                                                          height_shift_range=0.2,
                                                          rescale=1./255,
                                                          shear_range=0.2,
                                                          zoom_range=0.2,
                                                          horizontal_flip=True,
                                                          fill_mode='nearest')
image.getpixel
image_array = tf.keras.preprocessing.image.img_to_array(image)
image_array = image_array.reshape((1,) + image_array.shape)
count = 0
for batch in datagen.flow(image_new, batch_size=1, save_to_dir ='images_gen' , save_prefix='cat', save_format='jpeg'):
  count +=1
  if count==10:
    break
#显示输入图像

import matplotlib.pylab as plt
image = plt.imread('2.jpeg')
plt.imshow(image)
plt.show()

#在ImageDataGenerator之后显示图像

import matplotlib.pylab as plt
image = plt.imread('images_gen/cat_0_2229.jpeg')
plt.imshow(image)
plt.show()

清楚地解释你的问题,最好是用代码和错误部分。清楚地解释你的问题,最好是用代码和错误部分。