Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Lozac'h Loic
otbtf
Commits
999d3c69
Commit
999d3c69
authored
Mar 06, 2019
by
Cresson Remi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: add the clear_devices option, useful to wipe device assignment in graphs
parent
de2c2b11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
python/ckpt2savedmodel.py
python/ckpt2savedmodel.py
+4
-5
python/tricks.py
python/tricks.py
+2
-2
No files found.
python/ckpt2savedmodel.py
View file @
999d3c69
...
...
@@ -21,10 +21,7 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
from
tricks
import
*
# Logging
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
INFO
)
from
tricks
import
CheckpointToSavedModel
# Parser
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -32,10 +29,12 @@ parser.add_argument("--ckpt", help="checkpoint file prefix", required=True)
parser
.
add_argument
(
"--inputs"
,
help
=
"input placeholder names"
,
required
=
True
,
nargs
=
'+'
)
parser
.
add_argument
(
"--outputs"
,
help
=
"output placeholder names"
,
required
=
True
,
nargs
=
'+'
)
parser
.
add_argument
(
"--model"
,
help
=
"output SavedModel"
,
required
=
True
)
parser
.
add_argument
(
'--clear_devices'
,
dest
=
'clear_devices'
,
action
=
'store_true'
)
parser
.
set_defaults
(
clear_devices
=
False
)
params
=
parser
.
parse_args
()
if
__name__
==
"__main__"
:
CheckpointToSavedModel
(
params
.
ckpt
,
params
.
inputs
,
params
.
outputs
,
params
.
model
)
CheckpointToSavedModel
(
params
.
ckpt
,
params
.
inputs
,
params
.
outputs
,
params
.
model
,
params
.
clear_devices
)
quit
()
python/tricks.py
View file @
999d3c69
...
...
@@ -135,7 +135,7 @@ def CreateSavedModel(sess, inputs, outputs, directory):
builder
.
add_meta_graph
([
tf
.
saved_model
.
tag_constants
.
SERVING
])
builder
.
save
()
def
CheckpointToSavedModel
(
ckpt_path
,
inputs
,
outputs
,
savedmodel_path
):
def
CheckpointToSavedModel
(
ckpt_path
,
inputs
,
outputs
,
savedmodel_path
,
clear_devices
=
False
):
"""
Read a Checkpoint and build a SavedModel
...
...
@@ -149,7 +149,7 @@ def CheckpointToSavedModel(ckpt_path, inputs, outputs, savedmodel_path):
with
tf
.
Session
()
as
sess
:
# Restore variables from disk.
model_saver
=
tf
.
train
.
import_meta_graph
(
ckpt_path
+
".meta"
)
model_saver
=
tf
.
train
.
import_meta_graph
(
ckpt_path
+
".meta"
,
clear_devices
=
clear_devices
)
model_saver
.
restore
(
sess
,
ckpt_path
)
# Create a SavedModel
...
...
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