Just run the code with the proper file path in the dictionary filename
This code is a mixture of the above two.
I have stacked blocks of 10000 images after reading the data of 10000X28X28 bytes = 7840000 bytes at once.
And the time taken for reading 7840000 bytes at once and stacking them all in 6 iterations in a single numpy array to form a 3D array was about 5 seconds on my laptop.
The numpy arrays can further be converted to images using other libraries like opencv, PIL or scipy.
But for using in a CNN, keeping in the np.ndarray format will be useful. I guess!!
Run the file ndarr2img.py
Takes about less than 20 seconds for the trainiing images and much less than that for the test images.
Just enter the right path
The iamges will be saved in '.jpg' format
And the labels will be saved in '.npy' format