-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodeltest.py
47 lines (38 loc) · 1.63 KB
/
modeltest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import tensorflow as tf
from vision import eyemodel
modeldir = "C:\\Users\\AinL\\Documents\\Visual Studio Code\\eyegazemodels\\model eye1\\"
datasetdir = "C:\\Users\\AinL\\Documents\\Visual Studio Code\\eyegazemodels\\eyestest\\"
data = eyemodel.decodeData(datasetdir)
data.imagesize = 224
data.anglemul = 360
def loadGraph(path):
with tf.gfile.FastGFile(path, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
_ = tf.import_graph_def(graph_def, name='prefix')
return graph
def readGraphDef(path, data):
saver = tf.train.import_meta_graph(path)
graph = tf.get_default_graph()
for g in graph.get_operations():
print(g)
with tf.Session(graph=graph) as sess:
# To initialize values with saved data
saver.restore(sess, data)
def run():
print("start run")
g = loadGraph(modeldir + "frozen.pb")
for op in g.get_operations():
print(op)
# print(graph_def)
# with tf.Session() as sess:
# for i in range(10):
# batch_img, batch_label = data.batch(20)
# inp = sess.graph.get_tensor_by_name("input_image")
# output = sess.graph.get_tensor_by_name("output")
# fetches = sess.run([output], feed_dict={inp:batch_img})
# print(fetches)
if __name__ == "__main__":
readGraphDef("C:\\Users\\AinL\\Documents\\Visual Studio Code\\eyegazemodels\\model eye2\\24-06-2017 20-56-15 model.ckpt.meta",\
"C:\\Users\\AinL\\Documents\\Visual Studio Code\\eyegazemodels\\model eye2\\24-06-2017 20-56-15 model.ckpt.data-00000-of-00001")