diff --git a/ai.py b/ai.py index c99cde1..8f88230 100755 --- a/ai.py +++ b/ai.py @@ -1,9 +1,9 @@ # Arda Mavi import os import platform -import numpy as np +import numpy as np, skimage, imageio, matplotlib from time import sleep -from PIL import ImageGrab +from PIL import ImageGrab, Image from game_control import * from predict import predict from game_control import * diff --git a/create_dataset.py b/create_dataset.py index 1142edb..d84f451 100644 --- a/create_dataset.py +++ b/create_dataset.py @@ -1,13 +1,11 @@ -# Arda Mavi import os import sys import platform -import numpy as np +import numpy as np, skimage, imageio, matplotlib from time import sleep -from PIL import ImageGrab +from PIL import ImageGrab, Image from game_control import * from predict import predict -from scipy.misc import imresize from game_control import get_id from get_dataset import save_img from multiprocessing import Process @@ -18,7 +16,7 @@ def get_screenshot(): img = ImageGrab.grab() img = np.array(img)[:,:,:3] # Get first 3 channel from image as numpy array. - img = imresize(img, (150, 150, 3)).astype('float32')/255. + img = np.array(img, (150, 150, 3)).astype('float32')/255. return img def save_event_keyboard(data_path, event, key): diff --git a/get_dataset.py b/get_dataset.py index 0f1ca04..b53f617 100755 --- a/get_dataset.py +++ b/get_dataset.py @@ -1,18 +1,17 @@ -# Arda Mavi import os -import numpy as np +import numpy as np, skimage, imageio, matplotlib +from PIL import ImageGrab, Image from keras.utils import to_categorical -from scipy.misc import imread, imresize, imsave from sklearn.model_selection import train_test_split def get_img(data_path): # Getting image array from path: - img = imread(data_path) - img = imresize(img, (150, 150, 3)) + img = imageio.imread(data_path) + img = np.array(img, (150, 150, 3)) return img def save_img(img, path): - imsave(path, img) + imageio.imwrite(path, img) return def get_dataset(dataset_path='Data/Train_Data'): diff --git a/predict.py b/predict.py index 1e2f4a4..a5e5e2c 100755 --- a/predict.py +++ b/predict.py @@ -1,8 +1,8 @@ # Arda Mavi -import numpy as np -from scipy.misc import imresize +import numpy as np, skimage, imageio, matplotlib +from PIL import ImageGrab, Image def predict(model, X): - X = imresize(X, (150, 150, 3)).astype('float32')/255. + X = np.array(X, (150, 150, 3)).astype('float32')/255. Y = model.predict(X.reshape(1,150,150,3)) return Y