大神地址:https://github.com/gskielian/JPG-PNG-to-MNIST-NN-Format
一般在`Traceback (most recent call last):
File “convert-images-to-mnist-format.py”, line 47, in
header.append(int(‘0x’+hexval[2:][2:],16))
OverflowError: unsigned byte integer is greater than maximum
如果出现以上错误:
(1)查看‘’batches.meta.txt‘’ 序号标签是否匹配

(2)修改代码
import os
from PIL import Image
from array import *
from random import shuffle
# Load from and save to
Names = [['./training-images', 'train'], ['./test-images', 'test']]
for name in Names:
data_image = array('B')
data_label = array('B')
FileList = []
for dirname in os.listdir(name[0]): # [1:] Excludes .DS_Store from Mac OS
path = os.path.join(name[0], dirname)
for filename in os.listdir(path):
if filename.endswith(".png"):
FileList.append(os.path.join(name[0], dirname, filename))
shuffle(FileList) # Usefull for further segmenting the validation set

在使用特定转换脚本将PNG图像转换为MNIST格式时,遇到OverflowError:unsigned byte integer is greater than maximum。问题源于脚本中的十六进制转换。解决方案包括检查‘batches.meta.txt’文件中的序号标签是否正确匹配。
最低0.47元/天 解锁文章
5970

被折叠的 条评论
为什么被折叠?



