Skip to content

This is a digit recognition project, powered by Python, TensorFlow, and Jupyter Notebook for model training and evaluation, coupled with React.js for the frontend deployed on Vercel, enables the accurate identification of handwritten digits.

License

Notifications You must be signed in to change notification settings

XiandaDu/Digit-Recognition

Repository files navigation

Digit Recognition Project

This is a Python 3.11 project which implements digit recognition using a Convolutional Neural Network (CNN). The dataset utilized is MNIST. It contains handwritten digit images for training and validating the model's digit classification capabilities.

Project Structure

├── data/MNIST/raw
│   └── handwritten images used for training and testing.
│
├── frontend/digit_recog_frontend
│   └── frontend implementation of the model. It is a react projecct. 
│       See the README file in this folder for details. 
│                            
├── export.py (Converts a trained PyTorch model into an ONNX model.)
│
├── Main.ipynb (The Jupyter Notebook code. The model was firstly written in Jupyter, 
│               then converted into python code. It is equivalent to main.py.)
│                             
├── main.py (Contains the implementation of the CNN, the training, and the testing. )
│
├── model.py (The ONNX model generated by export.py.)
│
└── model_weights.pth (Trained PyTorch model params will be saved as model_weights.pth.)

Dependencies

  • torch
  • torchvision
  • numpy

You can install the required dependencies using the following command

pip install torch torchvision numpy

Running the Project

  1. Install Dependencies: Ensure that you have installed the required dependencies.
  2. Run the Code<\b>: Execute the main.py file in the project's root directory.
  3. Save Model<\b>: The result parameters of the model in the training will be saved in model_weights.pth. Run the export.py file to export the model as onnx.

Project Overview

Model Structure

The project utilizes a simple Convolutional Neural Network named CNN in main.py.

class CNN(nn.module):
    # ...(Model architecture)

Training and Testing

The training and testing functions are defined in main.py after the definition of the CNN model

def train(epoch):
    #... (Training function)
    
def test():
    #... (Testing function)

Postscript

The accuracy rate of running the test image dataset is around 98%.

However, it demonstrates difficulty in distinguishing 7 and 1 in real testing.

About

This is a digit recognition project, powered by Python, TensorFlow, and Jupyter Notebook for model training and evaluation, coupled with React.js for the frontend deployed on Vercel, enables the accurate identification of handwritten digits.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published