首页 > 代码库 > Chapter 5 Convert Image Set To LevelDB/LMDB
Chapter 5 Convert Image Set To LevelDB/LMDB
Caffe中convert_imageset projrct将图像数据转换成Caffe能读取的数据格式leveldb/lmdb
1.添加命令参数
在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/";该路径下为生成的文件,若之前已经生成过,再次执行代码时要确保没有重复文件,否则会报错。
2.执行代码,得到结果
生成的文件如下:
Chapter 5 Convert Image Set To LevelDB/LMDB
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。