Chapter 5 Convert Image Set To LevelDB/LMDB

Posted X.LYU

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.执行代码,得到结果

image

生成的文件如下:

image

以上是关于Chapter 5 Convert Image Set To LevelDB/LMDB的主要内容,如果未能解决你的问题,请参考以下文章

[Chapter 5] Reinforcement LearningFunction Approximation

[Chapter 5] Reinforcement LearningFunction Approximation

[Chapter 5] Reinforcement LearningFunction Approximation

有没有办法在现有变量上使用 Pillows“Image.convert()”?

Code-Convert:Image to base64

Chapter 2.0 TensorBoard 基本教程(GRAPHS,scale,histogram,image)