Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
5597d9cb
Commit
5597d9cb
authored
May 26, 2013
by
Davis King
Browse files
Starting to flesh out the python interface documentation a little more.
parent
f02cf7ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
0 deletions
+95
-0
dlib/add_python_module
dlib/add_python_module
+16
-0
python_examples/compile_dlib_python_module.bat
python_examples/compile_dlib_python_module.bat
+4
-0
python_examples/sequence_segmenter.py
python_examples/sequence_segmenter.py
+73
-0
tools/python/CMakeLists.txt
tools/python/CMakeLists.txt
+2
-0
No files found.
dlib/add_python_module
View file @
5597d9cb
...
@@ -4,6 +4,12 @@
...
@@ -4,6 +4,12 @@
# The macro takes the module name as its first argument and then a list of
# The macro takes the module name as its first argument and then a list of
# source files to compile into the module. See ../tools/python/CMakeLists.txt
# source files to compile into the module. See ../tools/python/CMakeLists.txt
# for an example.
# for an example.
#
# It also sets up a macro called install_${module_name}_to() where
# ${module_name} is whatever you named your module. This install_*_to() macro
# takes a folder name and creates an install target that will copy the compiled
# python module to that folder when you run "make install". Note that the path
# given to install_*_to() is relative to your CMakeLists.txt file.
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
"C:/Program Files (x86)/boost/boost_1_*"
"C:/Program Files (x86)/boost/boost_1_*"
...
@@ -54,5 +60,15 @@ macro(add_python_module module_name module_sources )
...
@@ -54,5 +60,15 @@ macro(add_python_module module_name module_sources )
OUTPUT_NAME ${module_name}
OUTPUT_NAME ${module_name}
)
)
endif()
endif()
macro(install_${module_name}_to path)
# Determine the path to our CMakeLists.txt file.
string(REPLACE "CMakeLists.txt" "" base_path ${CMAKE_CURRENT_LIST_FILE})
INSTALL(TARGETS ${module_name}_
LIBRARY DESTINATION ${base_path}/${path}
)
endmacro()
endmacro()
endmacro()
python_examples/compile_dlib_python_module.bat
0 → 100755
View file @
5597d9cb
mkdir
build
cd
build
cmake
../../tools/python
cmake
--build
.
--config
Release
--target
install
python_examples/sequence_segmenter.py
0 → 100644
View file @
5597d9cb
# You need to compile the dlib python interface before you can use this
# file. To do this, run compile_dlib_python_module.bat. You also need to
# have the boost-python library installed. On Ubuntu, this can be done easily by running
# the command: sudo apt-get install libboost-python-dev
# asfd
import
dlib
use_sparse_vects
=
False
if
use_sparse_vects
:
samples
=
dlib
.
sparse_vectorss
()
else
:
samples
=
dlib
.
vectorss
()
segments
=
dlib
.
rangess
()
if
use_sparse_vects
:
inside
=
dlib
.
sparse_vector
()
outside
=
dlib
.
sparse_vector
()
inside
.
append
(
dlib
.
pair
(
0
,
1
))
outside
.
append
(
dlib
.
pair
(
1
,
1
))
else
:
inside
=
dlib
.
vector
([
0
,
1
])
outside
=
dlib
.
vector
([
1
,
0
])
samples
.
resize
(
2
)
segments
.
resize
(
2
)
samples
[
0
].
append
(
outside
)
samples
[
0
].
append
(
outside
)
samples
[
0
].
append
(
inside
)
samples
[
0
].
append
(
inside
)
samples
[
0
].
append
(
inside
)
samples
[
0
].
append
(
outside
)
samples
[
0
].
append
(
outside
)
samples
[
0
].
append
(
outside
)
segments
[
0
]
segments
[
0
].
append
(
dlib
.
range
(
2
,
5
))
samples
[
1
].
append
(
outside
)
samples
[
1
].
append
(
outside
)
samples
[
1
].
append
(
inside
)
samples
[
1
].
append
(
inside
)
samples
[
1
].
append
(
inside
)
samples
[
1
].
append
(
inside
)
samples
[
1
].
append
(
outside
)
samples
[
1
].
append
(
outside
)
segments
[
1
].
append
(
dlib
.
range
(
2
,
6
))
params
=
dlib
.
segmenter_params
()
#params.be_verbose = True
params
.
window_size
=
1
params
.
use_high_order_features
=
False
params
.
C
=
1
print
"params:"
,
params
df
=
dlib
.
train_sequence_segmenter
(
samples
,
segments
,
params
)
print
len
(
df
.
segment_sequence
(
samples
[
0
]))
print
df
.
segment_sequence
(
samples
[
0
])[
0
]
print
df
.
weights
#res = dlib.test_sequence_segmenter(df, samples, segments)
res
=
dlib
.
cross_validate_sequence_segmenter
(
samples
,
segments
,
2
,
params
)
print
res
tools/python/CMakeLists.txt
View file @
5597d9cb
...
@@ -15,3 +15,5 @@ add_python_module(dlib
...
@@ -15,3 +15,5 @@ add_python_module(dlib
src/cca.cpp
src/cca.cpp
src/sequence_segmenter.cpp
src/sequence_segmenter.cpp
)
)
install_dlib_to
(
../../python_examples
)
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