【发布时间】:2017-10-06 08:47:15
【问题描述】:
我正在尝试通过 tensorflow 将图像大小调整为固定大小。 但我正在查看如下奇怪的结果。 original image --> resized image。 我写的简单代码在这里。只有在有问题的行 (resize_images) 被注释时,原始图像才会正确显示。我在 Ubuntu 16.04 中的 PIP 安装的 python 3.5 和 tensorflow 1.1 的 virtualenv 中的 pycharm 上运行它。
import tensorflow as tf
from PIL import Image
filenames = ['/home/cideep/Work/tensorflow/datasets/VOC-2012/VOC-2012-train/JPEGImages/2007_000032.jpg']
filename_queue = tf.train.string_input_producer(filenames, shuffle=False, num_epochs=1)
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
image = tf.image.decode_jpeg(value)
# PROBLEM HERE!
resized_image = tf.image.resize_images(image, [200, 200])
init = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
sess = tf.Session()
sess.run(init)
tf.train.start_queue_runners(sess=sess)
img = sess.run(resized_image)
print('image shape', img.shape)
img = Image.fromarray(img, "RGB")
img.show('image')
消息如下。
/home/cideep/Work/tensorflow/tfenv/bin/python /home/cideep/Work/tensorflow/mycodes/test_preproc.py
2017-05-08 19:59:54.029800: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-08 19:59:54.029818: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-08 19:59:54.029822: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-08 19:59:54.029825: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-08 19:59:54.029827: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-05-08 19:59:54.168591: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-05-08 19:59:54.168997: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: TITAN X (Pascal)
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:01:00.0
Total memory: 11.90GiB
Free memory: 11.43GiB
2017-05-08 19:59:54.169007: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-05-08 19:59:54.169023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-05-08 19:59:54.169032: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: TITAN X (Pascal), pci bus id: 0000:01:00.0)
image shape (200, 200, 3)
Process finished with exit code 0
【问题讨论】:
-
在 TF github 上创建一个 bug 并给他们你的图像
标签: tensorflow