1
ファイルにtensorflow画像を保存できませんので、私はtf.image.resize_image_with_crop_or_pad機能を選んだ:は、私は特定のサイズに画像のサイズを変更し、ファイルに保存する必要が
import tensorflow as tf
image_decoded = tf.image.decode_jpeg(tf.read_file('1.jpg'), channels=3)
cropped = tf.image.resize_image_with_crop_or_pad(image_decoded, 200, 200)
tf.write_file('2.jpg', cropped)
がエラーで失敗しました:
をTraceback (most recent call last):
File "/home/test/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 490, in apply_op
preferred_dtype=default_dtype)
File "/home/test/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/test/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 583, in _TensorTensorConversionFunction
% (dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype string for Tensor with dtype uint8: 'Tensor("control_dependency_3:0", shape=(200, 200, 3), dtype=uint8)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 15, in <module>
tf.write_file('2.jpg', cropped)
File "/home/test/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/gen_io_ops.py", line 694, in write_file
contents=contents, name=name)
File "/home/test/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 508, in apply_op
(prefix, dtypes.as_dtype(input_arg.type).name))
TypeError: Input 'contents' of 'WriteFile' Op has type uint8 that does not match expected type of string.
I)は、(tf.as_stringを使用して文字列にテンソルを変換しようとしたが、で墜落:
TypeError: DataType uint8 for attr 'T' not in list of allowed values: int32, int64, complex64, float32, float64, bool, int8
Linux MintでTensorflow v0.12.0-rc0を使用します
機能が不明です。画像のサイズ変更ページにはありませんが、[こちら](https://www.tensorflow.org/api_docs/python/image/cropping)のようなものがあります。 –
私の答えが役に立つと分かったら、それを受け入れてください – yuval