po naciśnieciu "e" sieć sie uczy, po podjeściu do prawego górnego odpalane jest prediction
This commit is contained in:
parent
5f198cde38
commit
a51f3e31dc
15
tiles.py
15
tiles.py
@ -13,6 +13,7 @@ import matplotlib.pyplot as plt
|
|||||||
import os
|
import os
|
||||||
import cv2
|
import cv2
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
import keras
|
||||||
from keras.models import Sequential
|
from keras.models import Sequential
|
||||||
from keras.layers import Dense, Dropout, Activation, Flatten
|
from keras.layers import Dense, Dropout, Activation, Flatten
|
||||||
from keras.layers import Conv2D, MaxPooling2D
|
from keras.layers import Conv2D, MaxPooling2D
|
||||||
@ -642,8 +643,8 @@ def prepare_img(filepath):
|
|||||||
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1) / 255
|
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1) / 255
|
||||||
|
|
||||||
|
|
||||||
def predict(model):
|
def predict(model,filepath):
|
||||||
return model.predict([prepare_img('directory')])
|
return model.predict([prepare_img(filepath)])
|
||||||
|
|
||||||
|
|
||||||
def result(prediction):
|
def result(prediction):
|
||||||
@ -733,6 +734,11 @@ def main():
|
|||||||
|
|
||||||
key = pygame.key.get_pressed()
|
key = pygame.key.get_pressed()
|
||||||
left, middle, right = pygame.mouse.get_pressed()
|
left, middle, right = pygame.mouse.get_pressed()
|
||||||
|
|
||||||
|
if key[pygame.K_e]:
|
||||||
|
X, y = create_training_data()
|
||||||
|
model = learn_neural_network(X,y)
|
||||||
|
|
||||||
if middle:
|
if middle:
|
||||||
waiterGo(mouseToNum())
|
waiterGo(mouseToNum())
|
||||||
elif right:
|
elif right:
|
||||||
@ -800,9 +806,12 @@ def main():
|
|||||||
if waiter.loc == [576, 32]:
|
if waiter.loc == [576, 32]:
|
||||||
if first_time:
|
if first_time:
|
||||||
number = np.random.randint(20)
|
number = np.random.randint(20)
|
||||||
image = pygame.image.load('test/' + str(number) + '.jpg')
|
path = ('test/' + str(number) + '.jpg')
|
||||||
|
image = pygame.image.load(path)
|
||||||
first_time = False
|
first_time = False
|
||||||
display_img(display, image)
|
display_img(display, image)
|
||||||
|
prediction = predict(model, path)
|
||||||
|
result(prediction)
|
||||||
else:
|
else:
|
||||||
first_time = True
|
first_time = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user