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
5597d9cb
Commit
5597d9cb
authored
May 26, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting to flesh out the python interface documentation a little more.
parent
f02cf7ca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
0 deletions
+95
-0
add_python_module
dlib/add_python_module
+16
-0
compile_dlib_python_module.bat
python_examples/compile_dlib_python_module.bat
+4
-0
sequence_segmenter.py
python_examples/sequence_segmenter.py
+73
-0
CMakeLists.txt
tools/python/CMakeLists.txt
+2
-0
No files found.
dlib/add_python_module
View file @
5597d9cb
...
...
@@ -4,6 +4,12 @@
# 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
# 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}
"C:/Program Files (x86)/boost/boost_1_*"
...
...
@@ -54,5 +60,15 @@ macro(add_python_module module_name module_sources )
OUTPUT_NAME ${module_name}
)
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()
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
src/cca.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