pix2pix tensorflow.python.framework.errors\u impl.InvalidArgumentError:断言失败:[Need value.shape>;=size,got][2 286 286 1][2 512 512 3]
我有pix2pix代码。我试图从txt文件的图像中学习,而不是从现有的jpg中学习。 所以我制作了一个1024×512的txt文件,就像现有的数据对一样。 但我得到了这个错误。 如何修复它?pix2pix tensorflow.python.framework.errors\u impl.InvalidArgumentError:断言失败:[Need value.shape>;=size,got][2 286 286 1][2 512 512 3],python,tensorflow,Python,Tensorflow,我有pix2pix代码。我试图从txt文件的图像中学习,而不是从现有的jpg中学习。 所以我制作了一个1024×512的txt文件,就像现有的数据对一样。 但我得到了这个错误。 如何修复它? # _URL = 'https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/facades.tar.gz' # path_to_zip = tf.keras.utils.get_file('facades.tar.gz',o
# _URL = 'https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/facades.tar.gz'
# path_to_zip = tf.keras.utils.get_file('facades.tar.gz',origin=_URL,extract=True)
#PATH = os.path.join(os.path.dirname(path_to_zip), 'facades/') #서로 합침
BUFFER_SIZE = 400
BATCH_SIZE = 4
IMG_WIDTH = 512
IMG_HEIGHT = 512
def load(image_file):
image = np.expand_dims(np.loadtxt(image_file),-1)
# image = tf.io.read_file(image_file)
# image = tf.image.decode_jpeg(image)
w = tf.shape(image)[1]
w = w // 2
real_image = image[:, :w, :]
input_image = image[:, w:, :]
input_image = tf.cast(input_image, tf.float32)
real_image = tf.cast(real_image, tf.float32)
return input_image, real_image
inp, re = load(PATH+'/train/115_PET_512_30.txt')
# casting to int for matplotlib to show the image
plt.figure()
plt.imshow(inp/255.0)
plt.figure()
plt.imshow(re/255.0)
def resize(input_image, real_image, height, width):
input_image = tf.image.resize(input_image, [height, width],
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
real_image = tf.image.resize(real_image, [height, width],
method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
return input_image, real_image
def random_crop(input_image, real_image):
stacked_image = tf.stack([input_image, real_image], axis=0)
cropped_image = tf.image.random_crop(stacked_image, size=[2, IMG_HEIGHT, IMG_WIDTH, 3])
return cropped_image[0], cropped_image[1]