cifar下载地址:
http://www.cs.toronto.edu/~kriz/cifar.html
http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz 162 MB
http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz 163 MB
此外还有matlab版,都不是图片原文件,格式为data_batch_1, data_batch_2, …, data_batch_5, 以及test_batch,每个10000条数据
data为100003072,labels为100001(0-9),label_names 存每个标签对应的物体名称(如label_names[0] == “airplane”)
1字节label+3072字节像素值=3073字节,没有多余分隔符
cifar准确率汇总:
http://rodrigob.github.io/are_we_there_yet/build/classification_datasets_results.html
cifar10官网代码:
https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10
https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10_estimator(多GPU版)
tf官网介绍cifar10:
https://www.tensorflow.org/tutorials/images/deep_cnn
###########图像分类实验################
cifar10图像分类(支持一个或多个GPU;貌似不能直接在tpu上跑,tpu的代码、接口都不一样,可以看下D:\tensorflow_models\models-master\official\mnist的mnist_tpu.py)
-
python cifar10_train.py --train_dir cifar10_train/ --data_dir cifar10_data/
colab gpu(Tesla K80)上:2622.4 examples/sec; 0.049 sec/batch;5s100步,100万步需要14h,10万步需要1.4h
本地cpu:229.5 examples/sec; 0.558 sec/batch;大概是10倍多速度
说明:会自动下载数据集,并进行数据增强(包括随机左右翻转、随机裁剪、随机调整亮度和对比度); -
python cifar10_eval.py --data_dir cifar10_data/ --eval_dir cifar10_eval/ --checkpoint_dir cifar10_train/
结果为:precision @ 1 = 0.864(10万步)
注意:如果run_once为false,那么eval会一直运行,并隔一段时间(eval_interval_secs)测一遍最新的检查点,中间会sleep
gpu训练得到的checkpoint在cpu上也是能eval的
训练自己的图像识别模型用slim模块(可使用迁移学习进行微调),只需根据自己的数据集制作tfrecord,并修改、添加部分代码即可,直接用现成的py,可指定只训练哪些层或全部训练,可对单张图像进行预测;