Is the input of `tf.image.resize_images` must have static shape?

前端 未结 3 1790
一整个雨季
一整个雨季 2021-01-24 03:51

I run the code below, it raises an ValueError: \'images\' contains no shape. Therefore I have to add the line behind # to set the static shape, but

3条回答
  •  广开言路
    2021-01-24 04:10

    No, tf.image.resize_images can handle dynamic shape

    file_queue = tf.train.string_input_producer(['./dog1.jpg'])
    # shape of dog1.jpg is (720, 720)
    
    reader = tf.WholeFileReader()
    file_name, content = reader.read(file_queue)
    img_raw = tf.image.decode_jpeg(content, 3) # size (?, ?, 3)  <= dynamic h and w
    # img_raw.set_shape([227,227,3])
    img_resized = tf.image.resize_images(img_raw, [227, 227])
    img_shape = tf.shape(img_resized)
    
    with tf.Session() as sess:
        print img_shape.eval() #[227, 227, 3]
    

    BTW, I am using tf v0.12, and there is no function called tf.image.decode_image, but I don't think it is important

提交回复
热议问题