3

我正在关注这个 tensorflow assignment,我在第一个问题中遇到了问题。我必须使用给定的代码加载和转储一些数据数据,但由于某种原因它不起作用。

我第一次遇到这个错误:

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

我通过安装解决了libfreeimage-dev但现在我有另一个错误是Could not load bitmap "FILE_PATH/FILE_NAME.png": No known reason

我已经验证了该文件存在并且确实存在。错误来自此函数:

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
4

0 回答 0