Skip to first unread message

tamar elazari

unread,
Feb 18, 2015, 6:09:35 AM2/18/15
to caffe...@googlegroups.com
So as I am trying to learn the lenet example some questions came up:
1) What is the classification goal exactly? Are we trying to classify all digits? Just a few? Where can I see some of the input data?
2) I have trained and tested lenet_iter_10000 by the tutorial. Now I would like to get some classifications examples, and not just loss and accuracy. How can I do that?
3) And even better so - how can I do that using matlab?

And last but not least 4) why isn't there any tutorial about those things?

Thanks.

Arghavan Arafati

unread,
Aug 25, 2015, 9:43:23 PM8/25/15
to Caffe Users
Hi,

I have same problems, Did you find any solution?

Manuel Rodriguez

unread,
Aug 26, 2015, 4:42:04 AM8/26/15
to Caffe Users
Am Mittwoch, 18. Februar 2015 12:09:35 UTC+1 schrieb tamar elazari:
>  And last but not least 4) why isn't there any tutorial about those
things?


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.

Guru Raj

unread,
Oct 16, 2015, 1:44:49 PM10/16/15
to Caffe Users
Hi Manuel,
The following code worked for me.

import numpy as np
import sys
import caffe
import os

caffe_root = '/caffe'
MODEL_FILE = '/caffe/examples/mnist/lenet.prototxt'
PRETRAINED = '/caffe/examples/mnist/lenet_iter_10000.caffemodel'
IMAGE_FILE = '/caffe/examples/mnist/two.png'#image path


input_image = caffe.io.load_image(IMAGE_FILE, color=False)

net = caffe.Classifier( MODEL_FILE, PRETRAINED )
prediction = net.predict([input_image])
print 'predicted class:', prediction[0].argmax()

Jason Borne

unread,
Jan 4, 2016, 6:23:54 AM1/4/16
to Caffe Users
The ufldl group has developed matlab programs to view the images and check the labels. Here is the link: http://ufldl.stanford.edu/wiki/index.php/Using_the_MNIST_Dataset
Reply all
Reply to author
Forward
0 new messages