Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
db1caa42
Commit
db1caa42
authored
Oct 31, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix PredictConfig. use inputs_desc adn tower_func for load-cpm
parent
bbb2ecc2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
65 deletions
+57
-65
examples/ConvolutionalPoseMachines/load-cpm.py
examples/ConvolutionalPoseMachines/load-cpm.py
+54
-60
tensorpack/predict/config.py
tensorpack/predict/config.py
+3
-5
No files found.
examples/ConvolutionalPoseMachines/load-cpm.py
View file @
db1caa42
...
...
@@ -44,14 +44,7 @@ def get_gaussian_map():
return
gaussian_map
.
reshape
((
1
,
368
,
368
,
1
))
class
Model
(
ModelDesc
):
def
_get_inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
368
,
368
,
3
),
'input'
),
InputDesc
(
tf
.
float32
,
(
None
,
368
,
368
,
15
),
'label'
),
]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
def
CPM
(
image
):
image
=
image
/
256.0
-
0.5
gmap
=
tf
.
constant
(
get_gaussian_map
())
...
...
@@ -108,7 +101,8 @@ class Model(ModelDesc):
def
run_test
(
model_path
,
img_file
):
param_dict
=
np
.
load
(
model_path
,
encoding
=
'latin1'
)
.
item
()
predict_func
=
OfflinePredictor
(
PredictConfig
(
model
=
Model
(),
inputs_desc
=
[
InputDesc
(
tf
.
float32
,
(
None
,
368
,
368
,
3
),
'input'
)],
tower_func
=
CPM
,
session_init
=
DictRestore
(
param_dict
),
input_names
=
[
'input'
],
output_names
=
[
'resized_map'
]
...
...
tensorpack/predict/config.py
View file @
db1caa42
...
...
@@ -27,7 +27,7 @@ class PredictConfig(object):
):
"""
Args:
model (ModelDescBase): t
he model t
o be used to obtain inputs_desc and tower_func.
model (ModelDescBase): to be used to obtain inputs_desc and tower_func.
inputs_desc ([InputDesc]):
tower_func: a callable which takes input tensors
...
...
@@ -35,8 +35,7 @@ class PredictConfig(object):
session. Defaults to :class:`tf.train.ChiefSessionCreator()`.
session_init (SessionInit): how to initialize variables of the session.
Defaults to do nothing.
input_names (list): a list of input tensor names. Defaults to all
inputs of the model.
input_names (list): a list of input tensor names. Defaults to match inputs_desc.
output_names (list): a list of names of the output tensors to predict, the
tensors can be any computable tensor in the graph.
return_input (bool): same as in :attr:`PredictorBase.return_input`.
...
...
@@ -70,8 +69,7 @@ class PredictConfig(object):
# inputs & outputs
self
.
input_names
=
input_names
if
self
.
input_names
is
None
:
raw_tensors
=
self
.
model
.
get_inputs_desc
()
self
.
input_names
=
[
k
.
name
for
k
in
raw_tensors
]
self
.
input_names
=
[
k
.
name
for
k
in
self
.
inputs_desc
]
self
.
output_names
=
output_names
assert_type
(
self
.
output_names
,
list
)
assert_type
(
self
.
input_names
,
list
)
...
...
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