This repository contains a complete workflow for training and evaluating an MNIST digit classification model using TensorFlow and Keras. It includes code for model training, evaluation, and inference using uploaded images.
mnist_model.keras
: The saved Keras model file for MNIST digit classification.MNIST_TSFlow+keras.ipynb
: Jupyter Notebook for training and saving the MNIST classification model.ModelExecution.ipynb
: Jupyter Notebook for loading the saved model and predicting digits from uploaded images.
The dataset used is MNIST provided by Zalando. It includes the following categories:
The model is a neural network with the following layers:
- Flatten Layer: Converts the 28x28 pixel images into a 1D array.
- Dense Layer 1: 1024 neurons, ReLU activation.
- Dense Layer 2: 256 neurons, ReLU activation.
- Dense Layer 3: 64 neurons, ReLU activation.
- Output Layer: 10 neurons, softmax activation for classification.
The model is trained for 50 epochs using the Adam optimizer and Sparse Categorical Crossentropy loss function.
Before running the notebooks, make sure to install the required packages. You can use the following commands to install them:
!pip install -U tensorflow_datasets
!pip install ipywidgets
This notebook is used to:
- Load the MNIST dataset using TensorFlow Datasets (TFDS).
- Normalize and preprocess the dataset.
- Train a neural network model to classify MNIST digits.
- Save the trained model to a file (
mnist_model.keras
).
This notebook is used to:
- Load the saved model (
mnist_model.keras
). - Upload images for prediction using a Colab file upload widget.
- Process the uploaded images and make predictions.
- Display the predicted class along with the confidence percentage.
-
Train and Save Model:
- Open and run the
MNIST_TSFlow+keras.ipynb
notebook. - This will train the model and save it as
mnist_model.keras
.
- Open and run the
-
Load Model and Predict:
- Open and run the
ModelExecution.ipynb
notebook. - Upload an image and observe the model's prediction.
- Open and run the
- Run the
ModelExecution.ipynb
notebook. - Use the upload widget to select an image file.
- The notebook will display the image along with the model’s prediction and confidence percentage.
This project is licensed under the MIT License - see the LICENSE file for details.