3

I'm following this tensorflow assignment and I have an issue in the first problem. I have to load and dump some data data using a given code but for some reason It's not working.

I first had this error:

Could not find a format to read the specified file in mode 'i'

That I solved by installing libfreeimage-dev but now I have another error which is Could not load bitmap "FILE_PATH/FILE_NAME.png": No known reason

I've already verified the file exists and it does. The error comes from this function:

def load_letter(folder, min_num_images):
  """Load the data for a single letter label."""
  image_files = os.listdir(folder)
  dataset = np.ndarray(shape=(len(image_files), image_size, image_size), dtype=np.float32)
  print(folder)
  num_images = 0
  for image in image_files:
    image_file = os.path.join(folder, image)
    try:
      image_data = (imageio.imread(image_file).astype(float) - pixel_depth / 2) / pixel_depth
      if image_data.shape != (image_size, image_size):
        raise Exception('Unexpected image shape: %s' % str(image_data.shape))
      dataset[num_images, :, :] = image_data
      num_images = num_images + 1
    except (IOError, ValueError) as e:
      print('Could not read:', image_file, ':', e, '- it\'s ok, skipping.')

  dataset = dataset[0:num_images, :, :]
  if num_images < min_num_images:
    raise Exception('Many fewer images than expected: %d < %d' % (num_images, min_num_images))

  print('Full dataset tensor:', dataset.shape)
  print('Mean:', np.mean(dataset))
  print('Standard deviation:', np.std(dataset))
  return dataset
Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55

0 Answers0