machine learning - A guide to convert_imageset.cpp -


i relatively new machine learning/python/ubuntu.

i have set of images in .jpg format half contain feature want caffe learn , half don't. i'm having trouble in finding way convert them required lmdb format.

i have necessary text input files.

my question can provide step step guide on how use convert_imageset.cpp in ubuntu terminal?

thanks

a quick guide caffe's convert_imageset

build

first thing must build caffe , caffe's tools (convert_imageset 1 of these tools).
after installing caffe , makeing make sure ran make tools well.
verify binary file convert_imageset created in $caffe_root/build/tools.

prepare data

images: put images in folder (i'll call here /path/to/jpegs/).
labels: create text file (e.g., /path/to/labels/train.txt) line per input image . example:

img_0000.jpeg 1
img_0001.jpeg 0
img_0002.jpeg 0

in example first image labeled 1 while other 2 labeled 0.

convert dataset

run binary in shell

~$ glog_logtostderr=1 $caffe_root/build/tools/convert_imageset \     --resize_height=200 --resize_width=200 --shuffle  \     /path/to/jpegs/ \     /path/to/labels/train.txt \     /path/to/lmdb/train_lmdb 

command line explained:

  • glog_logtostderr flag set 1 before calling convert_imageset indicates logging mechanism redirect log messages stderr.
  • --resize_height , --resize_width resize all input images same size 200x200.
  • --shuffle randomly change order of images , not preserve order in /path/to/labels/train.txt file.
  • following path images folder, labels text file , output name. note output name should not exist prior calling convert_imageset otherwise you'll scary error message.

other flags might useful:

  • --backend - allows choose between lmdb dataset or leveldb.
  • --gray - convert images gray scale.
  • --encoded , --encoded_type - keep image data in encoded (jpg/png) compressed form in database.
  • --help - shows help, see relevant flags under flags tools/convert_imageset.cpp

you can check out $caffe_root/examples/imagenet/convert_imagenet.sh example how use convert_imageset.

you can find more information in caffe's documentation.


Comments