Python tf.image.resize和cv2.resize:它们应该是相同的还是不同的?
Python tf.image.resize和cv2.resize:它们应该是相同的还是不同的?,python,tensorflow,keras,Python,Tensorflow,Keras,tf.image.resize中有一个臭名昭著的bug。现在我们有了tf2.0,但是我仍然不能用这个函数得到与ImageDataGenerator相同的结果 那么,这种方法是否应该与枕头和cv2中的方法相同?见详情 你希望从中得到什么样的答案?这似乎是一个应该问开发人员自己的问题,您希望从中得到什么样的答案?这似乎是一个应该问开发人员自己的问题 # we may get the same image image_tf = tf.io.read_file(str(image_path)) imag
tf.image.resize
中有一个臭名昭著的bug。现在我们有了tf2.0
,但是我仍然不能用这个函数得到与ImageDataGenerator
相同的结果
那么,这种方法是否应该与枕头
和cv2
中的方法相同?见详情
你希望从中得到什么样的答案?这似乎是一个应该问开发人员自己的问题,您希望从中得到什么样的答案?这似乎是一个应该问开发人员自己的问题
# we may get the same image
image_tf = tf.io.read_file(str(image_path))
image_tf = tf.image.decode_jpeg(image_tf, channels=3, dct_method='INTEGER_ACCURATE')
image_cv = cv2.imread(str(image_path))
image_cv = cv2.cvtColor(image_cv, cv2.COLOR_BGR2RGB)
np.sum(np.abs(image_cv - image_tf)) # 0
# but not the same resized image
image_tf_res = tf.image.resize(image_tf, IMAGE_SIZE, method='bilinear')
image_cv_res = cv2.resize(image_cv, tuple(IMAGE_SIZE), interpolation=cv2.INTER_LINEAR)
# this is NOT 0
np.sum(np.abs(image_cv_res - image_tf_res))