This is a python scripts convert MNist sklearn datasets into png file for better visualization of the datasets to be used for convolutional Neural Network.
The below code is used to load the Mnist dataset which contains already extracted features of 28x28 pixels of images.
from sklearn import datasets
dataset = datasets.fetch_mldata("MNIST Original")
But what if we dont need the already extracted features, what if we need the raw image so that we can also pass it through different convolutional layers and get more features about it.
That is why there is need for the dataset to be converted back to raw images so that we can perfome our operations on it.
The project contains the root python script, an input directory and output folder.
-
The scripts contains the conversion code, we just a one line cli to run it.
-
The input directory contains all the dataset we are able to lay our hands on, Downloaded from Yann LeCun Website http://yann.lecun.com/exdb/mnist/. you can also download the dataset from any other websites that offers this.
-
You will need an output directory where to store the converted images, and inside the out put folder, you need to create the training and testing folder to automatically split the converted images into training and testing.
To run this scripts, you will need to follow the command below <input_folder> and <output_folder> are the folder we created earlier.
python convert_mnist_to_png.py <input_folder> <output_folder>
This will iterate over the dataset extracted from Yann LeCun websites and converts them.
The converted files can be found in your ouput file supplied.
Below are sample images after conversion
Thanks.
contact me @ [email protected] for more information