Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python3-imagej-tiff
Project
Project
Details
Activity
Releases
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
Elphel
python3-imagej-tiff
Commits
8301c953
Commit
8301c953
authored
Sep 14, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+Saved Model model generation and running
parent
9ea88926
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
infer_qcds_graph_01.py
infer_qcds_graph_01.py
+21
-9
No files found.
infer_qcds_graph_01.py
View file @
8301c953
...
...
@@ -97,7 +97,7 @@ qsf.prepareFiles(dirs,
"""
Next is tag for pb (pb == protocol buffer) model
"""
PB_TAG
=
"model_pb"
PB_TAG
S
=
[
"model_pb"
]
print
(
"Copying config files to results directory:
\n
('
%
s' -> '
%
s')"
%
(
conf_file
,
dirs
[
'result'
]))
try
:
...
...
@@ -129,12 +129,25 @@ try:
except
:
pass
shutil
.
rmtree
(
dirs
[
'exportdir'
],
ignore_errors
=
True
)
builder
=
tf
.
saved_model
.
builder
.
SavedModelBuilder
(
dirs
[
'exportdir'
])
with
tf
.
Session
()
as
sess
:
infer_saver
=
tf
.
train
.
import_meta_graph
(
files
[
"inference"
]
+
'.meta'
)
# default option
use_saved_model
=
False
if
os
.
path
.
isdir
(
dirs
[
'exportdir'
]):
# check if dir contains "Saved Model" model
use_saved_model
=
tf
.
saved_model
.
loader
.
maybe_saved_model_directory
(
dirs
[
'exportdir'
])
if
use_saved_model
:
print
(
"Model restore: using Saved_Model model MetaGraph protocol buffer"
)
meta_graph_source
=
tf
.
saved_model
.
loader
.
load
(
sess
,
PB_TAGS
,
dirs
[
'exportdir'
])
else
:
print
(
"Model restore: using conventionally saved model, but saving Saved Model for the next run"
)
meta_graph_source
=
files
[
"inference"
]
+
'.meta'
shutil
.
rmtree
(
dirs
[
'exportdir'
],
ignore_errors
=
True
)
builder
=
tf
.
saved_model
.
builder
.
SavedModelBuilder
(
dirs
[
'exportdir'
])
infer_saver
=
tf
.
train
.
import_meta_graph
(
meta_graph_source
)
graph
=
tf
.
get_default_graph
()
ph_corr2d
=
graph
.
get_tensor_by_name
(
'ph_corr2d:0'
)
...
...
@@ -203,11 +216,10 @@ with tf.Session() as sess:
"""
image_data
[
nimg
]
=
None
# when saved tags can be read with saved_model_cli which is built from tensorflow source using bazel
builder
.
add_meta_graph_and_variables
(
sess
,[
PB_TAG
])
if
not
use_saved_model
:
builder
.
add_meta_graph_and_variables
(
sess
,
PB_TAGS
)
builder
.
save
()
if
lf
:
lf
.
close
()
writer
.
close
()
builder
.
save
()
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