-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScript.py
31 lines (22 loc) · 811 Bytes
/
Script.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
import tensorflow as tf
import NeuralNetwork
import os
import cv2
import time
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
cv2_image = cv2.imread("./images/Traffic.jpg")
NN = NeuralNetwork.Net(Debugging=True)
image = NN.image
resize_picture, picture = NN.preproces_image(cv2_image)
with tf.Session() as sess:
start = time.time()
sess.run(tf.global_variables_initializer())
prediction = sess.run(NN.predict(), feed_dict={image:picture})
print("Time took to compute: " + str((time.time()-start)*1000) + "ms")
#Save Network
saver = tf.train.Saver()
saver.save(sess, "./model/NN.ckpt")
tf.train.write_graph( sess.graph_def, "./model/", "NN.pb", as_text=False )
output_image, boxes = NN.postprocess(prediction, resize_picture, 0.3, 0.3)
cv2.imwrite("./images/test.jpg", output_image)
print("Done!!")