标签:
Caffe中convert_imageset projrct将图像数据转换成Caffe能读取的数据格式leveldb/lmdb
在main函数中添加命令参数,内容和位置如下:
#ifndef GFLAGS_GFLAGS_H_
namespace gflags = google;
#endif
//convert imageset By XiaopanLyu====================================================
argc = 12;
argv[0] = "convert_imageset";
argv[1] = "-gray=true";//whether read gray image
argv[2] = "-shuffle=true";//whether mix order
argv[3] = "-resize_height=28";
argv[4] = "-resize_width=28";
argv[5] = "-backend=lmdb";//leveldb/lmdb
argv[6] = "-check_size=false";
argv[7] = "-encoded=true";
argv[8] = "-encode_type=jpg";
argv[9] = "E:/MyCode/DL/caffe-master/examples/images/";
argv[10] = "E:/MyCode/DL/caffe-master/examples/convert_imageset/images_list.txt";
argv[11] = "E:/MyCode/DL/caffe-master/examples/convert_imageset/img_convert/";
//after read the [FLAGS] command, the argv & argc would be adjust automatically
//==================================================================================
gflags::SetUsageMessage("Convert a set of images to the leveldb/lmdb\n"
"format used as input for Caffe.\n"
"Usage:\n"
" convert_imageset [FLAGS] ROOTFOLDER/ LISTFILE DB_NAME\n"
"The ImageNet dataset for the training demo is at\n"
" http://www.image-net.org/download-images\n");
gflags::ParseCommandLineFlags(&argc, &argv, true);
Attention:
1)argv[10] = "E:/MyCode/DL/caffe-master/examples/convert_imageset/images_list.txt";该文件表示的是图像对应的标签,格式如下:
cat gray.jpg 1
cat.jpg 1
cat_gray.jpg 1
fish-bike.jpg 2
2)argv[11] = "E:/MyCode/DL/caffe-master/examples/convert_imageset/img_convert/";该路径下为生成的文件,若之前已经生成过,再次执行代码时要确保没有重复文件,否则会报错。
生成的文件如下:
Chapter 5 Convert Image Set To LevelDB/LMDB
标签:
原文地址:http://www.cnblogs.com/xiaopanlyu/p/5902896.html