Caffe学习:build/tools/convert_imageset

caffe/build/tools/convert_imageset用于将image图片转化为lmdb(leveldb)格式

  • 编写命令,实现图片格式转化:
#!bin/sh

# 工具目录
TOOLS_ROOT=caffe/build/tools

# train_datas存放训练图片
# label_train.txt保存图片标签
# shuffle参数用于打乱图片读取顺序
# train_db文件夹(不可手动新建)存放转换后的db文件
$TOOLS_ROOT/convert_imageset train_datas/ label_train.txt train_db --shuffle=true

# test_datas存放测试图片
# label_test.txt保存图片标签
# shuffle参数用于打乱图片读取顺序
# test_db文件夹(不可手动新建)存放转换后的db文件
$TOOLS_ROOT/convert_imageset test_datas/ label_test.txt test_db --shuffle=true
  • 具体参数详见caffe/tools/convert_imageset.cpp
DEFINE_bool(gray, false,
    "When this option is on, treat images as grayscale ones");
DEFINE_bool(shuffle, false,
    "Randomly shuffle the order of images and their labels");
DEFINE_string(backend, "lmdb",
        "The backend {lmdb, leveldb} for storing the result");
DEFINE_int32(resize_width, 0, "Width images are resized to");
DEFINE_int32(resize_height, 0, "Height images are resized to");
DEFINE_bool(check_size, false,
    "When this option is on, check that all the datum have the same size");
DEFINE_bool(encoded, false,
    "When this option is on, the encoded image will be save in datum");
DEFINE_string(encode_type, "",
    "Optional: What type should we encode the image as ('png','jpg',...).");

你可能感兴趣的:(caffe,caffe)