Caffe expects data to be in a specific format: CHW dimension order (channel, height, width), BGR channel order, 0-255 range.
caffe/io.py however uses
skimage to load images, which inputs HWC, RGB images in 0-1 range. OpenCV would load HWC too but BGR order and 0-255 range already - so depending on what library are you using to load images, you will need different transformations to make the data compatible with caffe. Additionally, you might want to do stuff like mean subtraction.
Transformer is a convenience class that packs all those transformations so you can do them in a single call to
preprocess() - you can perform the inverse transformation by
deprocess().
And yes if you trained your net on a data processed somehow, then you most likely need to do the same transformation for tests/deployment as well. If you forget to subtract mean or swap channels you will simply get weird results, but forgetting about transposition might lead to shape mismatches etc.