Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ai.py
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down
8 changes: 3 additions & 5 deletions create_dataset.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down
11 changes: 5 additions & 6 deletions get_dataset.py
Original file line number Diff line number Diff line change
@@ -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'):
Expand Down
6 changes: 3 additions & 3 deletions predict.py
Original file line number Diff line number Diff line change
@@ -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