我正在关注这个张量流作业,我在第一个问题中遇到了问题。我必须使用给定的代码加载和转储一些数据数据,但由于某种原因它不起作用。
我第一次遇到这个错误:
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
我遇到了同样的问题,在阅读了Nathan的评论后,我意识到我也遇到了类似的问题:我的文件也是空的。
就我而言,我使用 Git LFS 来跟踪
.png
文件,并将它们添加为 LFS 文件。为了解决这个问题,我必须使用以下命令显式提取这些文件:
git lfs pull --include "/path/to/files"
文件正确下载后,一切都会按预期进行。