Commit 44387e39 authored by Davis King's avatar Davis King

merged

parents 97ff8cb2 a88f1bd8
This diff is collapsed.
......@@ -10,8 +10,10 @@ import numpy as np
# dlib lenet model. Then you need to convert that model into a "dlib to caffe
# model" python script. You can do this using the command line program
# included with dlib: tools/convert_dlib_nets_to_caffe. That program will
# output a lenet_dlib_to_caffe_model.py file. This line here imports that
# file.
# output a lenet_dlib_to_caffe_model.py file. You run that program like this:
# ./dtoc lenet.xml 1 1 28 28
# and it will create the lenet_dlib_to_caffe_model.py file, which we import
# with the next line:
import lenet_dlib_to_caffe_model as dlib_model
# lenet_dlib_to_caffe_model defines a function, save_as_caffe_model() that does
......@@ -54,12 +56,12 @@ data = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,121,254,254,219,40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,121,254,207,18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype='float32');
data.shape = (dlib_model.batch_size, dlib_model.input_k, dlib_model.input_nr, dlib_model.input_nc);
data.shape = (dlib_model.input_batch_size, dlib_model.input_num_channels, dlib_model.input_num_rows, dlib_model.input_num_cols);
# labels isn't logically needed but there doesn't seem to be a way to use
# caffe's Net interface without providing a superfluous input array. So we do
# that here.
labels = np.ones((dlib_model.batch_size), dtype='float32')
labels = np.ones((dlib_model.input_batch_size), dtype='float32')
# Give the image to caffe
net.set_input_arrays(data/256, labels)
# Run the data through the network and get the results.
......@@ -67,7 +69,7 @@ out = net.forward()
# Print outputs, looping over minibatch. You should see that the network
# correctly classifies the image (it's the number 7).
for i in xrange(dlib_model.batch_size):
for i in xrange(dlib_model.input_batch_size):
print i, 'net final layer = ', out['fc1'][i]
print i, 'predicted number =', np.argmax(out['fc1'][i])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment