Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic image size [batch, None, None, 3] error. #41

Open
zsdonghao opened this issue Jun 25, 2017 · 11 comments
Open

Dynamic image size [batch, None, None, 3] error. #41

zsdonghao opened this issue Jun 25, 2017 · 11 comments

Comments

@zsdonghao
Copy link

Hi thank you for releasing this implementation.

I try to evaluate the model on images with different size, so I would like to define a placeholder as:

t_image = tf.placeholder('float32', [1, None, None, 3], name='input_image')

then when I use the subpixel layer, I will get:

    X = tf.reshape(I, (bsize, a, b, r, r))
  File "/ssd2/Workspace/env3/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2451, in reshape
    name=name)
  File "/ssd2/Workspace/env3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 508, in apply_op
    (input_name, err))
ValueError: Tried to convert 'shape' to a tensor and failed. Error: None values not supported.

Do you have any idea to solve this problem? if we cannot use dynamic size, we need to define different inference for different image, which is resource and time consuming.

Many thanks in advance.

@riokt
Copy link

riokt commented Aug 30, 2017

I got same problem.

@zsdonghao
Copy link
Author

@riokt I solved this problem, please check the SRGAN implementation https://github.com/zsdonghao/SRGAN

@riokt
Copy link

riokt commented Aug 31, 2017

@zsdonghao Nice. Thank you

@SystemErrorWang
Copy link

@zsdonghao Hello, I tried to contact you through tencent QQ, but mention again here if you didn't see it. Hope you can give me some help, thanks.
I tried to check your tensorlayer code but failed to figure out how you solve this problem. The subpixel conv2d is not capable of dealing with placeholder with shape [batch_size, None, None, 3] as tf.reshape is used, and I also tried to save and restore network parameters in npz file format, but tensorflow still give me this: "You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [?,48,48,3]". However, the tensorlayer based SRGAN code can test on a whole DIV2K image.
So I would like to know what method you used in tensorlayer that solved this problem.

@zsdonghao
Copy link
Author

@SystemErrorWang please update your TensorLayer version, it will support dynamic image size.

@SystemErrorWang
Copy link

@zsdonghao I tried the tensorlayer script and it succeeded, but still I would like to know if there is any method to deal with it in native tensorflow, thanks.

@zsdonghao
Copy link
Author

@SystemErrorWang hi, you can just simply copy the core codes from TensorLayer's layer.

@SystemErrorWang
Copy link

@zsdonghao Thank, I solved this problem
@riokt You can simply use tf.shape(X) to substitute X.get_shape() in PS() function, and set input placeholder to be shaped [None, None, None, 3]

@lhanappa
Copy link

@zsdonghao @SystemErrorWang
Hi, good day. As the implementation of Tensorlayer, if I understand correctly, the function of_phase_shift() is equal to "depth_to_space"?
https://www.tensorflow.org/api_docs/python/tf/nn/depth_to_space

@SystemErrorWang
Copy link

@lhanappa I didn't test this function myself, but I think they are theorically the same. Guess you can do some experiments.

@lhanappa
Copy link

@SystemErrorWang Thanks, yes, I already did.
"depth_to_space" and "space_to_depth" are two reciprocal functions for expanding/compressing channels in native tensorflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants