Программа для анализа изображения с камеры направленной на ж\д переезд (Томск, пл. Южная, ул. Мокрушина и Коларовский тракт). 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 1015B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #28x16 448 neurons
  2. from pyfann import libfann
  3. from PIL import Image
  4. import os
  5. datastruct = []
  6. files=[]
  7. learn=[]
  8. for filename in os.listdir("0"):
  9. if filename.endswith(".png"):
  10. files.append("0/"+filename)
  11. learn.append([0])
  12. for filename in os.listdir("1"):
  13. if filename.endswith(".png"):
  14. files.append("1/"+filename)
  15. learn.append([1])
  16. print len(files)
  17. print files
  18. print len(learn)
  19. print learn
  20. for filename in files:
  21. im = Image.open(filename, 'r')
  22. pixel_values = list(im.getdata(0))
  23. datastruct.append(pixel_values)
  24. desired_error = 0.001
  25. max_epochs = 1000
  26. epochs_between_reports = 1000
  27. ann = libfann.neural_net()
  28. ann.create_standard_array((448,150,1))
  29. ann.set_activation_function_hidden(libfann.SIGMOID_SYMMETRIC_STEPWISE)
  30. ann.set_activation_function_output(libfann.SIGMOID_SYMMETRIC_STEPWISE)
  31. train_data = libfann.training_data()
  32. train_data.set_train_data(datastruct, learn)
  33. ann.train_on_data(train_data,max_epochs, epochs_between_reports, desired_error)
  34. ann.save('fann.data')
  35. ann.destroy()