The question "how to classify images with a pretrained ".caffemodel"
is heavy posted in many forums. The answer is, that caffe is in early
development stage and has no easy interface for doing the job well. If
you want to play around with messy software you can try the following
python-script:
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
caffe_root = '/home/hp/temp/caffe/caffe/'
sys.path.insert(0, caffe_root + 'python')
import caffe
MODEL_FILE = '/home/hp/temp/caffe/mynet/trial6/lenet.prototxt'
PRETRAINED = '/home/hp/temp/caffe/mynet/trial6/lenet_iter_20000.caffemodel'
IMAGE_FILE = '/tmp/3/0026.jpg'
net = caffe.Classifier(MODEL_FILE, PRETRAINED)
prediction = net.predict([input_image])
print 'predicted class:', prediction[0].argmax()
But, it is 100% sure, that you will get any kinds of error while running
it. There are many pitfalls, e.g. if your input image has the wrong
resolution or the wrong numbers of colorchannels, you will get lots of
segmentation faults. It is also a problem in the documentation of caffe
that the step "classification" is not written well enough.