Browse Source

import

master
Vladimir Smagin 3 years ago
commit
120bab49f7

+ 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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


+ 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