码迷,mamicode.com
首页 > 数据库 > 详细

Chapter 5 Convert Image Set To LevelDB/LMDB

时间:2016-09-24 13:24:13      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/xiaopanlyu/p/5902896.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!