title: Creation of dataset for SRCNN - Tensorflow : Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
body: <p>I am trying to create a dataset containing high resolution images and their corresponding low resolution for a super resolution convolutionnal neural network</p>
  <p>Starting from the high resolution, I've created 2 lists (1 Ground truth and 1 low resolution) of images with same dimension.
  From <a href="https://keras.io/api/models/model_training_apis/" rel="nofollow noreferrer">https://keras.io/api/models/model_training_apis/</a> we can see that the input data should be a Numpy array so I also transformed it.</p>
  <pre><code>ds_lr = [] #Low resolution list
  ds_gt = [] #High resolution list
  #Degradation of GT image to lower resolution
  for filename in os.listdir(filepath_gt):
      img = cv2.imread(os.path.join(filepath_gt,filename))
      if img is not None:
          #Keep x percent of the pixel of the original picture
          width = int(img.shape[1] * config.SCALE_PERCENT  / 100)
          height = int(img.shape[0] * config.SCALE_PERCENT  / 100)
          
          # dsize
          dsize = (width, height)
          
          # Lower resolution Image
          output = cv2.resize(img, dsize, interpolation=None)
          
          #Resize low resolution image
          width_resize = int(output.shape[1]  / (config.SCALE_PERCENT/ 100))
          height_resize = int(output.shape[0] /(config.SCALE_PERCENT / 100))
          
          if width_resize != img.shape[1]:
              width_resize += 1
          if height_resize != img.shape[0]:
              height_resize += 1
              
          d_resize = (width_resize, height_resize)
          img_lr_resize = cv2.resize(output, d_resize)
  
          ds_lr.append(img_lr_resize/255)
          ds_gt.append(img/255)
  
  #Transforming the list in numpy array
  ds_lr_arr = np.asarray(ds_lr, dtype = object)
  ds_gt_arr = np.asarray(ds_gt, dtype = object)
  </code></pre>
  <p>When trying to use this to train my neural network, I encounter the following error: <strong>Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).</strong>
  Even while using <code>tf.convert_to_tensor</code>.</p>
  <pre><code>#Train CNN
  history = srcnn.fit(
      x = tf.convert_to_tensor(ds_lr),
      y = tf.convert_to_tensor(ds_gt),
      #x = ds_lr,
      #y = ds_gt,
      batch_size = config.BATCH_SIZE, 
      epochs = config.EPOCH,
      callbacks=[cp_callback],
      validation_split = 0.2
      )
  
  </code></pre>
  <p>I am wondering if this could be linked to the fact that each image of the list has a different size.</p>
  <p>Do you know a solution or alternative to this problem.</p>