热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_48320099
玛卡巴卡小仙爷
6 年前
trueweixin_48320099

求助,TypeError: only integer scalar arrays can be converted to a scalar index
代码如下:
import glob
import os
import cv2
import numpy as np
classification = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']
def unpickle(file):
import pickle
with open(file, 'rb') as fo:
dict = pickle.load(fo, encoding='bytes')
return dict
folders = r'地址'
trfiles = glob.glob(folders + "/data_batch*")
data = []
labels = []
for file in trfiles:
dt = unpickle(file)
data += list(dt[b"data"])
labels += list(dt[b"data"])
print(labels)
imgs = np.reshape(data, [-1, 3, 32, 32])
for i in range(imgs.shape[0]):
im_data = imgs[i, ...]
im_data = np.transpose(im_data, [1, 2, 0])
im_data = cv2.cvtColor(im_data, cv2.COLOR_RGB2BGR)
f = "{},{}".format(r'地址', classification[labels[i]])
if not os.path.exists(f):
os.mkdir(f)
cv2.imwrite("{}/{}.jpg".format(f, str(i)), im_data)

程序员写BUG的日常
CSDN App 扫码分享
分享
1
2
打赏
  • 复制链接
  • 举报
下一条:
java中一个接口,只能有一个父接口吗?
立即登录