Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
44387e39
Commit
44387e39
authored
May 24, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
97ff8cb2
a88f1bd8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
main.cpp
tools/convert_dlib_nets_to_caffe/main.cpp
+0
-0
running_a_dlib_model_with_caffe_example.py
..._nets_to_caffe/running_a_dlib_model_with_caffe_example.py
+7
-5
No files found.
tools/convert_dlib_nets_to_caffe/main.cpp
View file @
44387e39
This diff is collapsed.
Click to expand it.
tools/convert_dlib_nets_to_caffe/running_a_dlib_model_with_caffe_example.py
View file @
44387e39
...
...
@@ -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
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment