-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
57 lines (42 loc) · 1.42 KB
/
eval.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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
import os
import tensorflow as tf
import model
import params
import cv2
import numpy as np
sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore(sess, "./weight/SSC_epoch_14_LR_0.0001.model")
data_list = []
file_list = os.listdir('/raw_data/eval_data')
for file in file_list:
if file.endswith('.npy'):
file_location = "/raw_data/eval_data/" + file
loaded_data = np.load(file_location)
for data in loaded_data:
tmp = cv2.flip(data[0],0)
tmp = cv2.flip(tmp,1)
if params.img_channels != 3:
tmp = cv2.cvtColor(tmp, cv2.COLOR_BGR2GRAY)
img = (tmp[70:-5,::]).reshape(params.img_height, params.img_width, params.img_channels)
# change the can data (HEX) to numerical data
tmp = data[1]
hex_data = tmp[-23:-21] + tmp[-20:-18]
hex_decimal = tmp[-3:-1]
int_data = int(hex_data, 16)
int_decimal = int(hex_decimal, 16) / 256
# if the steering wheel angle in in right to the center
if(int_data > 550):
int_data = int_data - 4096
int_decimal = 1 - int_decimal
final_data = int_data - int_decimal
else:
# put the int and the decimal together
final_data = int_data + int_decimal
deg = model.y.eval(feed_dict={model.x: [img], model.keep_prob: 1.0})[0][0]
difference = ((final_data+16)-(deg+16))/(final_data+16)
if difference < 0:
difference = difference * -1
difference = difference * 100
print(deg, final_data, difference)