-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMat.py
More file actions
30 lines (20 loc) · 821 Bytes
/
testMat.py
File metadata and controls
30 lines (20 loc) · 821 Bytes
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
from PIL import Image
import numpy as np
import tensorflow as tf
import os
class TestMat:
def __init__(self, model_dir):
self.sess = tf.Session()
saver = tf.train.import_meta_graph(os.path.join(model_dir,"model.ckpt.meta"))
saver.restore(self.sess, tf.train.latest_checkpoint(model_dir))
print("类初始化成功")
def evaluate(self, image):
print("图像大小: ", image.shape)
inputX = self.sess.graph.get_tensor_by_name('x:0')
inputY = self.sess.graph.get_tensor_by_name('y:0')
op = self.sess.graph.get_tensor_by_name('op_to_store:0')
add_on_op = tf.multiply(op,2)
ret = self.sess.run(add_on_op,{inputX:5,inputY:5})
self.sess.close()
print("TF模型计算得到: ", ret)
return image