<p>Basically you can define a various size input using None as follows </p>

<pre><code>self.x = tf.placeholder(tf.float32, [1, None, None, 3]) 
</code></pre>

<p>and then you can feed different input</p>

<pre><code>feed_dict={self.x: current_data} etc..
</code></pre>

<p>But be careful about your neural net structure. If you flatten your last conv layer as input to the first dense layer then your network only works at that size, and you need to either stretch or crop the image to make it work.</p>

<p>A more flexible approach is to use something like <a href="https://www.quora.com/What-is-global-average-pooling" rel="nofollow noreferrer">Global Average Pooling</a> or <a href="https://arxiv.org/abs/1406.4729" rel="nofollow noreferrer">Spatial Pyramid Pooling</a> which both fix this problem.  </p>
Different image sizes in tensorflow with batch_size =1
<p>I want to achieve a python class, which can load a <code>tensorflow model</code> and implement a inference. However I have no idea about how can I input image with variable image size. :(</p>

<pre><code>class ArtGenerater():
    def __init__(self,model_path):
            self.model_path = model_path
            # vary shape?
            self.x = tf.placeholder(tf.float32,shape=(1,512,512,3))
            self.gen = model.resnet(self.x)
            self.out = tf.saturate_cast(self.gen,tf.uint8)

            self.sess = tf.Session()
            file = tf.train.lastest_checkpoint(self.model_path)
            saver = tf.train.Saver()
            saver.restore(self.sess,file)
    def pic(self,image_path):
            img =np.asarray(Image.open(image_path)).astype(np.float32)
            img = np.expand_dims(img,0)
            output_t = self.sess.run(self.out,feed_dict={self.x:img})
            return output_t
</code></pre>

<p>Now I just use <code>tf.placeholder(tf.float32,shape=(1,512,512,3))</code>,
but my image have different sizes(eg. 1000*900). </p>

<p>How can i achieve this function?
Thank you. </p>

<p><strong>EDIT:</strong></p>

<p>Thank you everyone.I have solved problem by using: </p>

<pre class="lang-py prettyprint-override"><code>x = tf.placeholder(tf.string)
img = tf.image.decode_jpeg(x,channels=3)
</code></pre>

<p>And this can feed network (my <code>ConvNet</code> include many <code>conv2d</code> &amp; <code>conv2d_tranpose</code>) with different image size. :)</p>