Skip to content

Import images into network

Tom Herold edited this page May 7, 2015 · 1 revision

##Importing images as Caffee Data Layers##

Caffe understands 4 different formats:

  • LevelDB / LMDB files
  • HDF5 files
  • direct image files from disc
  • memory access (input a matrix in code)

The LevelDB / LMDB (Symas Lightning Memory-Mapped Database; similar to LevelDB but quicker) option seems to be the most prominent approach and is used for the MNIST dataset example.

##How do I create my own LevelDB / LMDB?##

In you Caffee folder you will find a <Caffee>/build/convert_imageset binary that converts images to LevelDB or LMDB (default).

Usage

convert_imageset [FLAGS] ROOTFOLDER/ LISTFILE DB_NAME

Example

convert_imageset <path/to/image-net/archery> files.txt archery

LISTFILE is a text file that need the following format:

PATH_TO_IMAGE LABEL
PATH_TO_IMAGE LABEL
PATH_TO_IMAGE LABEL

The output is written to a new folder <DB_NAME> within you current working directory. Additionally the convert can do the following:

  • convert to greyscale
  • resize width/height
  • re-encode images as jpeg /png / etc
  • re-encode images as Caffee datum
  • shuffle the order of the images

##How do I configure a Data Layer / Input Layer for the network## See here: http://vision.stanford.edu/teaching/cs231n/slides/caffe_tutorial.pdf

Clone this wiki locally