converting set of jpgs to lmdb

2,560 views
Skip to first unread message

PC

unread,
Jul 15, 2015, 5:21:25 AM7/15/15
to caffe...@googlegroups.com
I have a set of images in jpg format where half contain a feature I want caffe to learn and half don't. I'm having trouble finding a way to convert them to the required lmdb format.
I have the necessary text input files. My question is can anyone provide a step by step guide on how to use convert_imageset.cpp?

Thanks, 


sharath s

unread,
Jul 15, 2015, 5:56:59 AM7/15/15
to caffe...@googlegroups.com
You can use the example script which comes along with Caffe

see create_imagenet.sh Script here caffe/examples/imagenet/create_imagenet.sh

change the script according to your paths for text files and the output(TRAIN_DATA_ROOT, VAL_DATA_ROOT)

contents of the text file for train.txt and val.txt should be

pic1.jpg 0
pic2.jpg 1
pic3.jpg 2

0,1,2 are category 0,1,2 respectively, if you change the script and run it, you should have the lmdb format.
Message has been deleted

PC

unread,
Jul 15, 2015, 6:43:21 AM7/15/15
to caffe...@googlegroups.com
Thanks for the quick response.

After changing the script according to my paths and running it, i get the following error:

./create_imagenet-Copy1.sh: 39: ./create_imagenet-Copy1.sh: build/tools/convert_imageset: not found
Creating val lmdb...
./create_imagenet-Copy1.sh: 49: ./create_imagenet-Copy1.sh: build/tools/convert_imageset: not found

i checked the build/tools directory and conert_imageset is there. Any thoughts?

sharath s

unread,
Jul 15, 2015, 7:06:53 AM7/15/15
to caffe...@googlegroups.com
I think you should give the full path

/home/xxx/caffe/build/tools/

Use full paths

PC

unread,
Jul 15, 2015, 12:05:02 PM7/15/15
to caffe...@googlegroups.com
I get the following error upon running convert_imageset.cpp; i.e "a total of 0 images"

Creating train lmdb...
I0715 16:54:06.121748  4120 convert_imageset.cpp:79] Shuffling data
I0715 16:54:06.122463  4120 convert_imageset.cpp:82] A total of 0 images.
I0715 16:54:06.123065  4120 db.cpp:34] Opened lmdb /home/pwhc/caffe/MY_TASK/lmdb/train_lmdb
Creating val lmdb...
I0715 16:54:06.196985  4122 convert_imageset.cpp:79] Shuffling data
I0715 16:54:06.197710  4122 convert_imageset.cpp:82] A total of 0 images.
I0715 16:54:06.198246  4122 db.cpp:34] Opened lmdb /home/pwhc/caffe/MY_TASK/lmdb/test_lmdb
Done.

Further thoughts?

sharath s

unread,
Jul 15, 2015, 12:38:40 PM7/15/15
to caffe...@googlegroups.com
Check your text file properly,

If the names inside the txt file is matching with the name of the images or not.

if one of the Image names doesnt match with the text file, it might be a problem.

Gavin Hackeling

unread,
Jul 15, 2015, 12:53:35 PM7/15/15
to sharath s, caffe...@googlegroups.com

Verify that the image filenames do not contain spaces.

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/bbd270b7-c843-4c83-a744-d802e149c1c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PC

unread,
Jul 15, 2015, 1:16:46 PM7/15/15
to caffe...@googlegroups.com, ssshar...@gmail.com
grateful for all the help given. stupid mistake in the end..


GLOG_logtostderr=1 $TOOLS/convert_imageset \
    --resize_height=$RESIZE_HEIGHT \
    --resize_width=$RESIZE_WIDTH \
    --shuffle \
    $TRAIN_DATA_ROOT \
    $DATA/train.txt \ # i included the file type when it should just have been  $DATA/train \
    $EXAMPLE/GPR_train_lmdb


Alec Wang

unread,
Jun 6, 2016, 9:39:32 PM6/6/16
to Caffe Users
Hi, if the label is a a vector, is the same way to convert?

在 2015年7月15日星期三 UTC+8下午5:56:59,sharath s写道:

GA_UP

unread,
Jul 22, 2018, 8:47:50 PM7/22/18
to Caffe Users

pic1.jpg 0
pic2.jpg 1
pic3.jpg 2

0,1,2 are category 0,1,2 respectively, if you change the script and run it, you should have the lmdb format.

What does these categories mean? I am relatively new to Caffe, pardon my ignorance.
Thank you so much! Any response is greatly appreciated.

Regrds,
Ga
Reply all
Reply to author
Forward
0 new messages