title: How to display images from tf.image.crop_and_resize
body: <p>I have to apply <code>tf.image.crop_and_resize</code> on my images and want to generate 5 boxes from each image. I have written the below code which works fine</p>
  <pre><code>import tensorflow as tf
  from tensorflow import keras
  from tensorflow.keras import layers
  import matplotlib.pyplot as plt
  import numpy as np
  
  # Load the pre-trained Xception model to be used as the base encoder.
  xception = keras.applications.Xception(
      include_top=False, weights=&quot;imagenet&quot;, pooling=&quot;avg&quot;
  )
  # Set the trainability of the base encoder.
  for layer in xception.layers:
    layer.trainable = False
  # Receive the images as inputs.
  inputs = layers.Input(shape=(299, 299, 3), name=&quot;image_input&quot;)
  
  input ='/content/1.png'
  
  input = tf.keras.preprocessing.image.load_img(input,target_size=(299,299,3))
  image = tf.expand_dims(np.asarray(input)/255, axis=0)
  BATCH_SIZE = 1
  NUM_BOXES = 5
  IMAGE_HEIGHT = 256
  IMAGE_WIDTH = 256
  CHANNELS = 3
  CROP_SIZE = (24, 24)
  
  
  boxes = tf.random.uniform(shape=(NUM_BOXES, 4))
  box_indices = tf.random.uniform(shape=(NUM_BOXES,), minval=0, maxval=BATCH_SIZE, dtype=tf.int32)
  
  
  output = tf.image.crop_and_resize(image, boxes, box_indices, CROP_SIZE)
  xception_input = tf.keras.applications.xception.preprocess_input(output)
  </code></pre>
  <p>The above code works fine however when I want to display these boxes I run below code</p>
  <pre><code>for i in range(5):
  
    # define subplot
    plt.subplot(330 + 1 + i)
  
    # generate batch of images
    batch = xception_input.next()
  
    # convert to unsigned integers for viewing
    image = batch[0].astype('uint8')
  
    image = np.reshape(24,24,3)
  
    # plot raw pixel data
    plt.imshow(image)
  
  #show the figure
  plt.show()
  </code></pre>
  <p>But it generates this error <code>AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'next'</code>.</p>