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
6e9382a3
Commit
6e9382a3
authored
Sep 18, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tag_constant
parent
6e3f3149
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
infer_qcds_01.py
infer_qcds_01.py
+8
-2
infer_qcds_graph_01.py
infer_qcds_graph_01.py
+9
-4
No files found.
infer_qcds_01.py
View file @
6e9382a3
...
@@ -219,8 +219,11 @@ tf.add_to_collection(collection_io, stage1done)
...
@@ -219,8 +219,11 @@ tf.add_to_collection(collection_io, stage1done)
tf.add_to_collection(collection_io, stage2_out_sparse)
tf.add_to_collection(collection_io, stage2_out_sparse)
"""
"""
##saver=tf.train.Saver()
##saver=tf.train.Saver()
saver
=
tf
.
train
.
Saver
(
tf
.
global_variables
())
saver
=
tf
.
train
.
Saver
(
tf
.
global_variables
())
#saver2 =tf.train.Saver(tf.global_variables()+tf.local_variables())
saver_def
=
saver
.
as_saver_def
()
saver_def
=
saver
.
as_saver_def
()
pass
pass
"""
"""
saver_def = saver.as_saver_def()
saver_def = saver.as_saver_def()
...
@@ -250,7 +253,10 @@ with tf.Session() as sess:
...
@@ -250,7 +253,10 @@ with tf.Session() as sess:
sess
.
run
(
tf
.
global_variables_initializer
())
sess
.
run
(
tf
.
global_variables_initializer
())
sess
.
run
(
tf
.
local_variables_initializer
())
sess
.
run
(
tf
.
local_variables_initializer
())
saver
.
restore
(
sess
,
files
[
"checkpoints"
])
saver
.
restore
(
sess
,
files
[
"checkpoints"
])
saver
.
save
(
sess
,
files
[
"inference"
])
#TODO: move to different subdir
saver
.
save
(
sess
,
files
[
"inference"
])
#TODO: move to different subdir
#saver2.save(sess, files["inference"]+"_2") #TODO: move to different subdir
merged
=
tf
.
summary
.
merge_all
()
merged
=
tf
.
summary
.
merge_all
()
writer
=
tf
.
summary
.
FileWriter
(
ROOT_PATH
,
sess
.
graph
)
writer
=
tf
.
summary
.
FileWriter
(
ROOT_PATH
,
sess
.
graph
)
lf
=
None
lf
=
None
...
...
infer_qcds_graph_01.py
View file @
6e9382a3
...
@@ -97,7 +97,7 @@ qsf.prepareFiles(dirs,
...
@@ -97,7 +97,7 @@ qsf.prepareFiles(dirs,
"""
"""
Next is tag for pb (pb == protocol buffer) model
Next is tag for pb (pb == protocol buffer) model
"""
"""
PB_TAGS
=
[
"model_pb"
]
#
PB_TAGS = ["model_pb"]
print
(
"Copying config files to results directory:
\n
('
%
s' -> '
%
s')"
%
(
conf_file
,
dirs
[
'result'
]))
print
(
"Copying config files to results directory:
\n
('
%
s' -> '
%
s')"
%
(
conf_file
,
dirs
[
'result'
]))
try
:
try
:
...
@@ -139,10 +139,12 @@ with tf.Session() as sess:
...
@@ -139,10 +139,12 @@ with tf.Session() as sess:
if
use_saved_model
:
if
use_saved_model
:
print
(
"Model restore: using Saved_Model model MetaGraph protocol buffer"
)
print
(
"Model restore: using Saved_Model model MetaGraph protocol buffer"
)
meta_graph_source
=
tf
.
saved_model
.
loader
.
load
(
sess
,
PB_TAGS
,
dirs
[
'exportdir'
])
meta_graph_source
=
tf
.
saved_model
.
loader
.
load
(
sess
,
[
tf
.
saved_model
.
tag_constants
.
SERVING
]
,
dirs
[
'exportdir'
])
else
:
else
:
print
(
"Model restore: using conventionally saved model, but saving Saved Model for the next run"
)
print
(
"Model restore: using conventionally saved model, but saving Saved Model for the next run"
)
meta_graph_source
=
files
[
"inference"
]
+
'.meta'
meta_graph_source
=
files
[
"inference"
]
+
'.meta'
print
(
"MetaGraph source = "
+
str
(
meta_graph_source
))
#meta_graph_source = files["inference"]+'_2.meta'
# remove 'exportdir' even it exsits and has anything
# remove 'exportdir' even it exsits and has anything
shutil
.
rmtree
(
dirs
[
'exportdir'
],
ignore_errors
=
True
)
shutil
.
rmtree
(
dirs
[
'exportdir'
],
ignore_errors
=
True
)
builder
=
tf
.
saved_model
.
builder
.
SavedModelBuilder
(
dirs
[
'exportdir'
])
builder
=
tf
.
saved_model
.
builder
.
SavedModelBuilder
(
dirs
[
'exportdir'
])
...
@@ -164,6 +166,7 @@ with tf.Session() as sess:
...
@@ -164,6 +166,7 @@ with tf.Session() as sess:
sess
.
run
(
tf
.
local_variables_initializer
())
sess
.
run
(
tf
.
local_variables_initializer
())
infer_saver
.
restore
(
sess
,
files
[
"inference"
])
# after initializers, of course
infer_saver
.
restore
(
sess
,
files
[
"inference"
])
# after initializers, of course
#infer_saver.restore(sess, files["inference"]+"_2") # after initializers, of course
merged
=
tf
.
summary
.
merge_all
()
merged
=
tf
.
summary
.
merge_all
()
writer
=
tf
.
summary
.
FileWriter
(
ROOT_PATH
,
sess
.
graph
)
writer
=
tf
.
summary
.
FileWriter
(
ROOT_PATH
,
sess
.
graph
)
...
@@ -217,8 +220,10 @@ with tf.Session() as sess:
...
@@ -217,8 +220,10 @@ with tf.Session() as sess:
image_data
[
nimg
]
=
None
image_data
[
nimg
]
=
None
if
not
use_saved_model
:
if
not
use_saved_model
:
builder
.
add_meta_graph_and_variables
(
sess
,
PB_TAGS
)
#builder.add_meta_graph_and_variables(sess,PB_TAGS)
builder
.
save
()
builder
.
add_meta_graph_and_variables
(
sess
,[
tf
.
saved_model
.
tag_constants
.
SERVING
])
#builder.save(True)
builder
.
save
(
False
)
if
lf
:
if
lf
:
lf
.
close
()
lf
.
close
()
...
...
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