1
0

Add some steps

This commit is contained in:
Jip J. Dekker 2018-05-25 14:37:32 +10:00
parent 9b4c4bf909
commit 2a00c812fb

View File

@ -3,6 +3,7 @@ from keras.models import Model, load_model
from keras.utils import to_categorical
import cv2
from skimage import color, exposure
from _cutter import image_cut
def man_result_check():
pred_y = np.load("predicted_results.npy")
@ -14,7 +15,7 @@ def man_result_check():
z = 0
for i in range(0, len(test_y)):
print(pred_y[i], test_y[i], file=f)
# Calculates correct predictions
# Calculates correct predictions
if pred_y[i][0] == test_y[i][0]:
z+=1
@ -25,7 +26,7 @@ def man_result_check():
Purpose:Loads a trained neural network model (using Keras) to classify an image
Input: path/to/trained_model
image [or] path/to/image [if from_file=True]
Returns:Boolean variable
Returns:Boolean variable
'''
def is_Wally(trained_model_path, image, from_file=False):
if from_file:
@ -50,5 +51,22 @@ def is_Wally(trained_model_path, image, from_file=False):
# Mark Wally image somehow (colour the border)
# Stitch original image back together
if __name__ == '__main__':
# Read image
image = cv2.imread("10.jpg")
# Split image
cuts = image_cut(image, 64, 64)
for i in len(cuts):
# Transform block
hsv = color.rgb2hsv(cuts[i])
hsv[:, :, 2] = exposure.equalize_hist(hsv[:, :, 2])
block = color.hsv2rgb(hsv)
block = np.rollaxis(block, -1)
if is_Wally("Waldo.h5", block):
# Border block
cuts[i] = cv2.copyMakeBorder(cuts[i],5,5,5,5,cv2.BORDER_CONSTANT,value=RED)
is_Wally("Waldo.h5", image)
# Stitch image TODO!
# Show image
cv.imshow('Image', image)
cv.waitKey(0)