import keras
from keras.models import load_model
from PIL import Image
import matplotlib.pylab as plt
import numpy as np
import zipfile
print("Extract")
zip_ref = zipfile.ZipFile("./asset.zip", 'r')
zip_ref.extractall(".")
zip_ref.close()
print("Load Model")
model=load_model("cifar-model.h5")
CIFAR_10_CLASSES=["Plane","Car","bird","cat","deer","dog","frog","horse","ship","truck"]
def calc(imname):
    test_image =Image.open("asset/"+imname)
    test_image=test_image.resize((32,32),Image.ANTIALIAS)
    test_image=np.array(test_image,dtype="float32")
    test_image/=255
    test_image=test_image.reshape(-1,32,32,3)
    predictions=model.predict(test_image)
    index_max_pred=np.argmax(predictions)
    plt.title("Complete: {}".format(CIFAR_10_CLASSES[index_max_pred]))
    plt.imshow(test_image[0].reshape(32,32,3))
    print(predictions)
    plt.show()
print("START TEST")
calc("lkw-image.jpg")
calc("cat.jpg")
calc("frog.jpg")
calc("fog.jpg")
calc("lfog.jpg")
calc("d.jpg")
calc("b.jpg")
calc("bs.jpg")
calc("plapper.jpg")
calc("ds.jpg")
print("Complete")
print("End")
quit(0)

[(8, 'zipfile.ZipFile', 'zipfile.ZipFile', False, 'import zipfile\n'), (12, 'keras.models.load_model', 'load_model', False, 'from keras.models import load_model\n'), (15, 'PIL.Image.open', 'Image.open', False, 'from PIL import Image\n'), (17, 'numpy.array', 'np.array', True, 'import numpy as np\n'), (21, 'numpy.argmax', 'np.argmax', True, 'import numpy as np\n'), (25, 'matplotlib.pylab.show', 'plt.show', True, 'import matplotlib.pylab as plt\n')]