Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# unzip the test file to read images
!unzip /content/drive/My\ Drive/test_ScVgIM0.zip
# Read test file names
test = pd.read_csv('test.csv')
test_copy = test.copy()
# Read test images and preprocess
test_image = []
for i in tqdm(range(test.shape[0])):
img = image.load_img('test/'+test['id'][i].astype('str')+'.png', target_size=(28,28,1), grayscale=True)
img = image.img_to_array(img)
img = img/255
test_image.append(img)
test = np.array(test_image)
# Make Predictions using the trained model
prediction = model.predict_classes(test)
# Write submission file to score
submission['id'] = test_copy['id']
submission['label'] = prediction
submission.to_csv('submission_cnn.csv', header=True, index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.