Git Product home page Git Product logo

mnist-classification-basic's Introduction

MNIST Model with TensorFlow and Keras

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.

Repository Contents

  • 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.

Dataset

The dataset used is MNIST provided by Zalando. It includes the following categories:

image

Model Architecture

The model is a neural network with the following layers:

  1. Flatten Layer: Converts the 28x28 pixel images into a 1D array.
  2. Dense Layer 1: 1024 neurons, ReLU activation.
  3. Dense Layer 2: 256 neurons, ReLU activation.
  4. Dense Layer 3: 64 neurons, ReLU activation.
  5. Output Layer: 10 neurons, softmax activation for classification.

Training

The model is trained for 50 epochs using the Adam optimizer and Sparse Categorical Crossentropy loss function.

Prerequisites

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

MNIST_TSFlow+keras.ipynb

This notebook is used to:

  1. Load the MNIST dataset using TensorFlow Datasets (TFDS).
  2. Normalize and preprocess the dataset.
  3. Train a neural network model to classify MNIST digits.
  4. Save the trained model to a file (mnist_model.keras).

ModelExecution.ipynb

This notebook is used to:

  1. Load the saved model (mnist_model.keras).
  2. Upload images for prediction using a Colab file upload widget.
  3. Process the uploaded images and make predictions.
  4. Display the predicted class along with the confidence percentage.

How to Use

  1. 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.
  2. Load Model and Predict:

    • Open and run the ModelExecution.ipynb notebook.
    • Upload an image and observe the model's prediction.

Uploading an Image

  1. Run the ModelExecution.ipynb notebook.
  2. Use the upload widget to select an image file.
  3. The notebook will display the image along with the model’s prediction and confidence percentage.

License

This project is licensed under the MIT License - see the LICENSE file for details.

mnist-classification-basic's People

Contributors

dakshverma11 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.