No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eval.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. import os
  3. import tensorflow as tf
  4. import model
  5. import params
  6. import cv2
  7. import numpy as np
  8. sess = tf.InteractiveSession()
  9. saver = tf.train.Saver()
  10. saver.restore(sess, "./weight/SSC_epoch_14_LR_0.0001.model")
  11. data_list = []
  12. file_list = os.listdir('/raw_data/eval_data')
  13. for file in file_list:
  14. if file.endswith('.npy'):
  15. file_location = "/raw_data/eval_data/" + file
  16. loaded_data = np.load(file_location)
  17. for data in loaded_data:
  18. tmp = cv2.flip(data[0],0)
  19. tmp = cv2.flip(tmp,1)
  20. if params.img_channels != 3:
  21. tmp = cv2.cvtColor(tmp, cv2.COLOR_BGR2GRAY)
  22. img = (tmp[70:-5,::]).reshape(params.img_height, params.img_width, params.img_channels)
  23. # change the can data (HEX) to numerical data
  24. tmp = data[1]
  25. hex_data = tmp[-23:-21] + tmp[-20:-18]
  26. hex_decimal = tmp[-3:-1]
  27. int_data = int(hex_data, 16)
  28. int_decimal = int(hex_decimal, 16) / 256
  29. # if the steering wheel angle in in right to the center
  30. if(int_data > 550):
  31. int_data = int_data - 4096
  32. int_decimal = 1 - int_decimal
  33. final_data = int_data - int_decimal
  34. else:
  35. # put the int and the decimal together
  36. final_data = int_data + int_decimal
  37. deg = model.y.eval(feed_dict={model.x: [img], model.keep_prob: 1.0})[0][0]
  38. difference = ((final_data+16)-(deg+16))/(final_data+16)
  39. if difference < 0:
  40. difference = difference * -1
  41. difference = difference * 100
  42. print(deg, final_data, difference)