Browse Source

import

master
Vladimir Smagin 4 years ago
commit
120bab49f7
45 changed files with 212 additions and 0 deletions
  1. +5
    -0
      README.md
  2. +10
    -0
      check.sh
  3. +15
    -0
      detect.py
  4. +34
    -0
      fann.data
  5. BIN
      learn/0/17_52-1.png
  6. BIN
      learn/0/17_52-2.png
  7. BIN
      learn/0/17_52-3.png
  8. BIN
      learn/0/17_52-4.png
  9. BIN
      learn/0/17_52-5.png
  10. BIN
      learn/0/17_52-6.png
  11. BIN
      learn/0/17_58-1.png
  12. BIN
      learn/0/17_58-2.png
  13. BIN
      learn/0/17_58-3.png
  14. BIN
      learn/0/17_58-4.png
  15. BIN
      learn/0/17_58-5.png
  16. BIN
      learn/0/17_58-6.png
  17. BIN
      learn/0/day_nt-1.png
  18. BIN
      learn/0/stream6-27198.ts1.png
  19. BIN
      learn/0/stream6-27198.ts5.png
  20. BIN
      learn/0/vech-nt-2.png
  21. BIN
      learn/1/18_14-1.png
  22. BIN
      learn/1/18_14-2.png
  23. BIN
      learn/1/18_14-3.png
  24. BIN
      learn/1/18_14-4.png
  25. BIN
      learn/1/18_14-5.png
  26. BIN
      learn/1/18_14-6.png
  27. BIN
      learn/1/morning-t-snow-1.png
  28. BIN
      learn/1/morning-t-snow-2.png
  29. BIN
      learn/1/morning-t-snow-4.png
  30. BIN
      learn/1/morning-t-snow-6.png
  31. BIN
      learn/1/morning-t-snow-7.png
  32. BIN
      learn/1/stream6-27563.ts1.png
  33. BIN
      learn/1/stream6-27563.ts2.png
  34. BIN
      learn/1/stream6-27563.ts3.png
  35. BIN
      learn/1/stream6-27563.ts4.png
  36. BIN
      learn/1/stream6-27563.ts5.png
  37. BIN
      learn/1/stream6-27563.ts6.png
  38. BIN
      learn/1/vech-t-1.png
  39. BIN
      learn/1/vech-t-2.png
  40. BIN
      learn/1/vech-t-3.png
  41. +34
    -0
      learn/fann.data
  42. +11
    -0
      learn/grab.sh
  43. +42
    -0
      learn/learn.py
  44. +57
    -0
      learn/learn.py.bak
  45. +4
    -0
      learn/learn.sh

+ 5
- 0
README.md View File

@ -0,0 +1,5 @@
Copyright by 21h
21h@blindage.org
http://blindage.org
"Do anything you want" license.

+ 10
- 0
check.sh View File

@ -0,0 +1,10 @@
#!/bin/bash
stream=$(curl -s http://cdn08.vtomske.ru/hls/stream6.m3u8|grep stream|head -n 1)
echo $stream
curl -s http://cdn08.vtomske.ru/hls/$stream > temp.ts
ffmpeg -loglevel panic -i "temp.ts" -filter:v "crop=28:16:1099:491" "temp_cropped.mp4"
ffmpeg -loglevel panic -i "temp_cropped.mp4" -vf fps=1 "detect_images/%d.png"
python detect.py
rm temp.ts temp_cropped.mp4 detect_images/*

+ 15
- 0
detect.py View File

@ -0,0 +1,15 @@
from pyfann import libfann
from PIL import Image
ann = libfann.neural_net()
ann.create_from_file('fann.data')
imdir="detect_images"
files = ["1.png"]
im = Image.open(imdir+"/"+files[0], 'r')
pix = list(im.getdata(0))
res = ann.run(pix)
print res
if res[0]>0.7:
print "Train!"
else:
print "Road clear"

+ 34
- 0
fann.data
File diff suppressed because it is too large
View File


BIN
learn/0/17_52-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_52-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_52-3.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_52-4.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_52-5.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_52-6.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/0/17_58-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/17_58-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/17_58-3.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/17_58-4.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/17_58-5.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/17_58-6.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/day_nt-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.1 KiB

BIN
learn/0/stream6-27198.ts1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/0/stream6-27198.ts5.png View File

Before After
Width: 28  |  Height: 16  |  Size: 996 B

BIN
learn/0/vech-nt-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/18_14-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/18_14-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/18_14-3.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/18_14-4.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/18_14-5.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/18_14-6.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/morning-t-snow-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/morning-t-snow-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/morning-t-snow-4.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/morning-t-snow-6.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/morning-t-snow-7.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/stream6-27563.ts1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/stream6-27563.ts2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/stream6-27563.ts3.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.3 KiB

BIN
learn/1/stream6-27563.ts4.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/stream6-27563.ts5.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/stream6-27563.ts6.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.2 KiB

BIN
learn/1/vech-t-1.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/1/vech-t-2.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

BIN
learn/1/vech-t-3.png View File

Before After
Width: 28  |  Height: 16  |  Size: 1.4 KiB

+ 34
- 0
learn/fann.data
File diff suppressed because it is too large
View File


+ 11
- 0
learn/grab.sh View File

@ -0,0 +1,11 @@
#!/bin/bash
HM=$(date +"%H_%M")
echo $HM
stream=$(curl -s http://cdn08.vtomske.ru/hls/stream6.m3u8|grep stream|head -n 1)
echo $stream
curl -s http://cdn08.vtomske.ru/hls/$stream > temp.ts
ffmpeg -loglevel panic -i "temp.ts" -filter:v "crop=28:16:1099:491" "temp_cropped.mp4"
ffmpeg -loglevel panic -i "temp_cropped.mp4" -vf fps=1 "$1/$HM-%d.png"
rm temp.ts temp_cropped.mp4

+ 42
- 0
learn/learn.py View File

@ -0,0 +1,42 @@
#28x16 448 neurons
from pyfann import libfann
from PIL import Image
import os
datastruct = []
files=[]
learn=[]
for filename in os.listdir("0"):
if filename.endswith(".png"):
files.append("0/"+filename)
learn.append([0])
for filename in os.listdir("1"):
if filename.endswith(".png"):
files.append("1/"+filename)
learn.append([1])
print len(files)
print files
print len(learn)
print learn
for filename in files:
im = Image.open(filename, 'r')
pixel_values = list(im.getdata(0))
datastruct.append(pixel_values)
desired_error = 0.001
max_epochs = 1000
epochs_between_reports = 1000
ann = libfann.neural_net()
ann.create_standard_array((448,150,1))
ann.set_activation_function_hidden(libfann.SIGMOID_SYMMETRIC_STEPWISE)
ann.set_activation_function_output(libfann.SIGMOID_SYMMETRIC_STEPWISE)
train_data = libfann.training_data()
train_data.set_train_data(datastruct, learn)
ann.train_on_data(train_data,max_epochs, epochs_between_reports, desired_error)
ann.save('fann.data')
ann.destroy()

+ 57
- 0
learn/learn.py.bak View File

@ -0,0 +1,57 @@
#28x16 448 neurons
from pyfann import libfann
from PIL import Image
files = ["stream6-27198.ts1.png", #no train
"stream6-27198.ts5.png", #no train
"day_nt-1.png", #no train
"vech-nt-2.png", #no train
"stream6-27563.ts1.png",
"stream6-27563.ts2.png",
"stream6-27563.ts3.png",
"stream6-27563.ts4.png",
"stream6-27563.ts5.png",
"stream6-27563.ts6.png",
"stream6-27563.ts1d.png",
"stream6-27563.ts2d.png",
"morning-t-snow-1.png",
"morning-t-snow-2.png",
"morning-t-snow-4.png",
"morning-t-snow-6.png",
"morning-t-snow-7.png",
"vech-t-1.png",
"vech-t-2.png",
"vech-t-3.png",
]
datastruct = []
for filename in files:
im = Image.open(filename, 'r')
pixel_values = list(im.getdata(0))
datastruct.append(pixel_values)
print len(datastruct[0])
desired_error = 0.001
max_epochs = 1000
epochs_between_reports = 1000
print "1"
ann = libfann.neural_net()
print "2"
#ann.create_standard(num_layers, num_input, num_neurons_hidden, num_output)
ann.create_standard_array((448,150,1))
print "5"
ann.set_activation_function_hidden(libfann.SIGMOID_SYMMETRIC_STEPWISE)
print "6"
ann.set_activation_function_output(libfann.SIGMOID_SYMMETRIC_STEPWISE)
print "3"
train_data = libfann.training_data()
print "4"
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]])
print "7"
ann.train_on_data(train_data,max_epochs, epochs_between_reports, desired_error)
print "8"
ann.save('fann.data')
print "9"
ann.destroy()

+ 4
- 0
learn/learn.sh View File

@ -0,0 +1,4 @@
#!/bin/bash
python learn.py
cp fann.data ../

Loading…
Cancel
Save