Created
August 23, 2021 16:10
A python script to automate the creation of a mnist dataset in csv format from raw mnist images
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
import os | |
for name in ['training', 'testing']: | |
with open('mnist_dataset_{}.csv'.format(name), 'w') as output_file: | |
print('=== creating {} dataset ==='.format(name)) | |
output_file.write('image_path,label\n') | |
for i in range(10): | |
path = '{}/{}'.format(name, i) | |
for file in os.listdir(path): | |
if file.endswith(".png"): | |
output_file.write('{},{}\n'.format(os.path.join(path, file), str(i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment