Skip to content

ghosteater1311/Hand-written_Digits_Recognition

Repository files navigation

Hand-written_Digits_Recognition

Team size: 4 people

  • Project Field: Computer Vision, Image Processing, Convolution Neutral Network, K-Nearest Neighbour, Classification Problem.

This project explores and compares two machine learning approaches—K Nearest Neighbors (KNN) and Convolutional Neural Networks (CNN)—for classifying handwritten digits from the MNIST dataset and human-generated input. It includes experiments on distance metrics, filter configurations, dropout rates, and model size. A custom GUI tool is also provided for users to draw digits and evaluate model performance on real-time human input. The source code for GUI tool is in this repository, the experiments is conducted through Kaggle.

Kaggle Notebooks

The following Kaggle notebooks were used for experiments and comparisons:

  • Compare Model: A notebook comparing the performance of KNN and CNN on human generated data.
  • Intro to CNN: A notebook exploring Convolutional Neural Networks (CNN) for digit classification.
  • Intro to KNN: A notebook exploring k-Nearest Neighbors (KNN) for digit classification.

Python Files

main.py

  • The main application file for the digit recognition GUI.
  • Allows users to draw digits on a canvas and predicts the digit using a pre-trained CNN model (final_model.h5).

ultility/drawer.py

  • Provides a utility for drawing and saving digit images.
  • Includes functionality to save drawn digits as 28x28 grayscale images in a CSV file.

ultility/show.py

  • Displays digit images from a CSV file (digit_data1.csv).
  • Visualizes the pixel data and corresponding labels.

ultility/showMNIST.py

  • Loads and visualizes digit images from the MNIST dataset.
  • Useful for understanding the structure of the dataset.

Additional Files

requirements.txt

  • Lists the Python dependencies required to run the project.

digit_data1.csv

  • A CSV file containing centerd and rezized human generated digit data, including labels and pixel values.

final_model.h5

  • The pre-trained CNN model used for digit recognition.

How to Run

Since tensorflow doesn't support python 3.13, we need to create a virtual enviroment to install tensorflow. If you are using python 3.12 or older, you don't need to create a virtual enviroment.

  1. Create a virtual environment with Python 3.11:

    python3.11 -m venv .venv
  2. Activate the virtual environment:

    • On Windows:
      .venv\\Scripts\\activate
    • On Linux/Mac:
      source .venv/bin/activate
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Run the main application:

    python main.py

About

A GUI Application that recognize the real time hand-written digits from user.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages