<p dir="auto">I'm setting up what (I think) should be a straightforward image loading pipeline:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="decoded_image = tf.image.decode_jpeg(value)
resized_image = tf.image.resize_image_with_crop_or_pad(decoded_image, width, height)"><pre class="notranslate"><span class="pl-s1">decoded_image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">decode_jpeg</span>(<span class="pl-s1">value</span>)
<span class="pl-s1">resized_image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">resize_image_with_crop_or_pad</span>(<span class="pl-s1">decoded_image</span>, <span class="pl-s1">width</span>, <span class="pl-s1">height</span>)</pre></div>
<p dir="auto">However, I get an error <code class="notranslate">'image' must be fully defined.</code> - the image not being fully defined because the size of the JPEG is variable. When using the <code class="notranslate">tf.image.resize_images()</code> function, it seems that this constraint is not enforced. Is it necessary to have fixed image dimensions to use the <code class="notranslate">resize_image_with_crop_or_pad()</code> function? That would seem to somewhat defeat the point of an auto-crop/resizing function, no?</p>
<p dir="auto">Because <code class="notranslate">tf.image.resize_image_with_crop_or_pad()</code> requires its input to have a fully defined shape, it's not useful as part of an input pipeline since the size of images loaded will not be known in advance.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  queue = tf.train.string_input_producer(filenames)
  reader = tf.WholeFileReader()
  _, contents = reader.read(queue)
  image = tf.image.decode_jpeg(contents, channels=3)
  cropped = tf.image.resize_image_with_crop_or_pad(image, 224, 224)"><pre class="notranslate">  <span class="pl-s1">queue</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">train</span>.<span class="pl-en">string_input_producer</span>(<span class="pl-s1">filenames</span>)
  <span class="pl-s1">reader</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">WholeFileReader</span>()
  <span class="pl-s1">_</span>, <span class="pl-s1">contents</span> <span class="pl-c1">=</span> <span class="pl-s1">reader</span>.<span class="pl-en">read</span>(<span class="pl-s1">queue</span>)
  <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">decode_jpeg</span>(<span class="pl-s1">contents</span>, <span class="pl-s1">channels</span><span class="pl-c1">=</span><span class="pl-c1">3</span>)
  <span class="pl-s1">cropped</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">image</span>.<span class="pl-en">resize_image_with_crop_or_pad</span>(<span class="pl-s1">image</span>, <span class="pl-c1">224</span>, <span class="pl-c1">224</span>)</pre></div>
<p dir="auto">Ideally the above would work...</p>