Skip to content

Instantly share code, notes, and snippets.

View nidhaloff's full-sized avatar
💭
I may be slow to respond.

Nidhal Baccouri nidhaloff

💭
I may be slow to respond.
View GitHub Profile
@nidhaloff
nidhaloff / gist:6537bb4c76790af86f0567435c8618b8
Created August 23, 2021 16:10
A python script to automate the creation of a mnist dataset in csv format from raw mnist images
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)))