Программа для анализа изображения с камеры направленной на ж\д переезд (Томск, пл. Южная, ул. Мокрушина и Коларовский тракт). http://blindage.org/?p=8212
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.

learn.py.bak 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #28x16 448 neurons
  2. from pyfann import libfann
  3. from PIL import Image
  4. files = ["stream6-27198.ts1.png", #no train
  5. "stream6-27198.ts5.png", #no train
  6. "day_nt-1.png", #no train
  7. "vech-nt-2.png", #no train
  8. "stream6-27563.ts1.png",
  9. "stream6-27563.ts2.png",
  10. "stream6-27563.ts3.png",
  11. "stream6-27563.ts4.png",
  12. "stream6-27563.ts5.png",
  13. "stream6-27563.ts6.png",
  14. "stream6-27563.ts1d.png",
  15. "stream6-27563.ts2d.png",
  16. "morning-t-snow-1.png",
  17. "morning-t-snow-2.png",
  18. "morning-t-snow-4.png",
  19. "morning-t-snow-6.png",
  20. "morning-t-snow-7.png",
  21. "vech-t-1.png",
  22. "vech-t-2.png",
  23. "vech-t-3.png",
  24. ]
  25. datastruct = []
  26. for filename in files:
  27. im = Image.open(filename, 'r')
  28. pixel_values = list(im.getdata(0))
  29. datastruct.append(pixel_values)
  30. print len(datastruct[0])
  31. desired_error = 0.001
  32. max_epochs = 1000
  33. epochs_between_reports = 1000
  34. print "1"
  35. ann = libfann.neural_net()
  36. print "2"
  37. #ann.create_standard(num_layers, num_input, num_neurons_hidden, num_output)
  38. ann.create_standard_array((448,150,1))
  39. print "5"
  40. ann.set_activation_function_hidden(libfann.SIGMOID_SYMMETRIC_STEPWISE)
  41. print "6"
  42. ann.set_activation_function_output(libfann.SIGMOID_SYMMETRIC_STEPWISE)
  43. print "3"
  44. train_data = libfann.training_data()
  45. print "4"
  46. train_data.set_train_data(datastruct, [[0],[0],[0],[0],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]])
  47. print "7"
  48. ann.train_on_data(train_data,max_epochs, epochs_between_reports, desired_error)
  49. print "8"
  50. ann.save('fann.data')
  51. print "9"
  52. ann.destroy()