视觉集
视觉数据库是用来提供给图片识别领域用素材,目前各个教材常用的主要有手写数字识别库、10中小图片分类库,详细介绍如下:
Mnist
MNIST(Mixed National Institute of Standards and Technology database)是一个计算机视觉数据集,它包含70000张手写数字的灰度图片,其中每一张图片包含 28 X 28 个像素点。可以用一个二维数字数组来表示这张图片,因为它单色只有一个通道计算会方便一些。
Cifar-10
该数据集主要是由三位作者收集、整理而成,来用于图像识别领域,其中包含60000张图片,50000是训练集,10000是测试集,每一张图片为32323个像素点,它比手写数字图片稍微复杂一点,它有RGB三个颜色通道,方便以后的爱好者专注于提高算法能力不用单独去为很多训练数据耽误太多时间,现今很多教材或者课程也都是基于这些数据集来讲解课程知识。
实战
下载
网上搜索即可
def load_data(path):
'''
加载数据图片
:param path:
:return:
'''
f = np.load(path)
x_train, y_train = f['x_train'], f['y_train']
x_test, y_test = f['x_test'], f['y_test']
f.close()
return (x_train, y_train), (x_test, y_test)
查看
def plot_images_labels_prediction(images,labels,prediction,idx,num=10):
fig = plt.gcf()
fig.set_size_inches(12,14)
if num>25:num=25
for i in range(0,num):
ax = plt.subplot(5,5,1+i)
ax.imshow(images[idx],cmap='binary')
title = 'label='+str(labels[idx])
if len(prediction)>0:
title+=",predict="+str(prediction[idx])
ax.set_tit