Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.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

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
Python tf.image.decode\u jpeg返回错误的图像_Python_Tensorflow - Fatal编程技术网

Python tf.image.decode\u jpeg返回错误的图像

Python tf.image.decode\u jpeg返回错误的图像,python,tensorflow,Python,Tensorflow,原始与重建像素之间的总差异:12563624 我试图将图像加载到tensorflow中,但像素差异明显太大,并且重建图像上的颜色与原始图像不符 import tensorflow as tf import matplotlib.pyplot as plt import cv2 import numpy as np sess = tf.Session() jpg1 = cv2.imread("test2.jpg") jpg2 = tf.read_file("test2.jpg") jpg

原始与重建像素之间的总差异:12563624

我试图将图像加载到tensorflow中,但像素差异明显太大,并且重建图像上的颜色与原始图像不符

import tensorflow as tf
import matplotlib.pyplot as plt
import cv2 
import numpy as np
sess = tf.Session()


jpg1 = cv2.imread("test2.jpg") 

jpg2 = tf.read_file("test2.jpg")
jpg2 = tf.image.decode_jpeg(jpg2) 
jpg2 = sess.run(jpg2) 


cv2.imshow('jpg1', jpg1)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imshow('jpg2', jpg2)
cv2.waitKey(0)
cv2.destroyAllWindows()