- 图像转为imdb格式
用的是caffe/build/tools/里面的 convert_imageset,参数如下:
convert_imageset [FLAGS] ROOTFOLDER/ LISTFILE DB_NAME
FLAG:
-backend :lmdb/leveldb for storing the result, default: “lmdb”
-gray (When this option is on, treat images as grayscale ones) type: bool
default: false
-resize_height (Height images are resized to) type: int32 default: 0
-resize_width (Width images are resized to) type: int32 default: 0
-shuffle (Randomly shuffle the order of images and their labels) type: bool
default: false
参照例子,我写了一个shell文件 create.sh
#!/usr/bin/env sh
# This script converts the image data into leveldb/lmdb format.
TOOLS=/home/chuny/Downloads/caffe/build/tools
RESIZE_HEIGHT=256
RESIZE_WIDTH=256
DATADIR=/home/chuny/temp/datadir
DATA=/home/chuny/temp/data
echo "Creating train leveldb..."
GLOG_logtostderr=1
$TOOLS/convert_imageset \
--resize_height=$RESIZE_HEIGHT \
--resize_width=$RESIZE_WIDTH \
--shuffle \
$DATADIR/ \
$DATA/train.txt \
$DATA/train_imdb
echo "Creating val leveldb..."
GLOG_logtostderr=1
$TOOLS/convert_imageset \
--resize_height=$RESIZE_HEIGHT \
--resize_width=$RESIZE_WIDTH \
--shuffle \
$DATADIR/ \
$DATA/val.txt \
$DATA/val_imdb