2016-06-12 3 views
0

tf.image.resize_image_with_crop_or_pad을 사용하여 입력 이미지의 일부를 자르고 싶습니다. 하지만 오류가 발생합니다 : ValueError: 'image' must be fully defined. 그리고 Tensor.set_shape()을 추가 한 Why do I get ValueError('\'image\' must be fully defined.') when transforming image in Tensorflow?을 확인했지만 작동하지도 않습니다. 나는 다음과 같이 내 코드와 오류를 나열 :Tensorflow : Tensor.set_shape() ValueError : 'image'가 완전히 정의되어야합니다.

example = tf.image.decode_png(file_contents, channels=3) 
example.set_shape = ([256,256,3]) 
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size) 

오류 : 오류가 나오는 심지어 내가 이미지에 특정 모양을 설정하는 이유

File "/home/kang/Documents/work_code_PC1/VGG_tensorflow_UCMerced/readUClandUsedImagetxt.py", line 97, in _input_pipeline 
    crop_image = tf.image.resize_image_with_crop_or_pad(image, crop_size, crop_size) 

    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 534, in resize_image_with_crop_or_pad 
    _Check3DImage(image, require_static=True) 

    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 221, in _Check3DImage 
    raise ValueError('\'image\' must be fully defined.') 

ValueError: 'image' must be fully defined. 

내가 모르겠어요. 하지만이 코드는 다음과 같이 테스트합니다.

example = tf.image.decode_png(file_contents, channels=3) 
example = tf.reshape(example, [256,256,3]) 
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size) 

이 작동합니다. Tensor에서 같은 모양으로 변형하면 값의 순서가 바뀌지 않는다고 생각합니다. 맞습니까? 어쩌면 그것은 해결책 일 수 있습니다.

답변

1

문제는 당신은 방법 tf.Tensor.set_shape을 무시하고 값으로 설정하는

example.set_shape = ([256,256,3]) 

라인에있다.

example.set_shape([256,256,3]) 

그 후, 코드가 작동합니다

set_shape

따라서 제대로 호출해야하는 방법입니다.

I think reshape to the same shape does not change the order of values in Tensor, am I right?

예, 당신은

+0

아 맞아. 고맙습니다. 그건 바보 같은 실수 야. –

관련 문제