Created
March 17, 2020 11:13
-
-
Save frenzy2106/8c7276b463a169b46690f7da4dfab802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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