Skip to content

exiort/BareRecognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BareRecognizer: Digit Recognition with Custom CNN (BareCNN)

This project demonstrates a basic digit recognition application using a custom Convolutional Neural Network (CNN) framework, BareCNN, and the MNIST dataset. It includes scripts for training a LeNet-5 model and making predictions on new images.

📁 Project Structure

.
├── .venv/
├── barerecognizer/
│   ├── core/
│   │   ├── image_preprocessing.py
│   │   └── model.py
│   └── scripts/
│       ├── predict.py
│       └── train.py
├── testdata/
├── lenet5.npz
├── main.py
└── requirements.txt
  • barerecognizer/: Contains the core logic and scripts for image preprocessing, model definition (LeNet-5), training, and prediction.
  • testdata/: Folder for custom handwritten digit images created on Gimp.
  • lenet5.npz: A pre-trained LeNet-5 model for quick testing.
  • main.py: Command-line interface for training and prediction.
  • requirements.txt: External Python dependencies.

🚀 Getting Started

Prerequisites

  • Python 3.x
  • BareCNN library must be accessible in your Python environment.

Installation

# Clone this repository:
git clone https://github.com/exiort/BareRecognizer.git
cd BareRecognizer

# Install dependencies:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Ensure BareCNN is accessible:
pip install /path/to/BareCNN

💡 Usage

The main.py script handles training and prediction.

🔧 Training the Model

To train a new LeNet-5 model:

python main.py train <epochs> <batch_size> <evaluate_on_test_set> <save_path>

Example:

python main.py train 10 64 1 my_lenet5_model.npz

This trains the model for 10 epochs, evaluates it on the test set, and saves the weights.

🔍 Predicting Digits

To predict digits using a trained model:

python main.py predict <model_path> <invert_image> <image_path_1> [image_path_2 ...]

Example:

python main.py predict lenet5.npz 1 testdata/digit_8-1.png testdata/digit_3-2.png

📄 License

MIT License. See the LICENSE file.

About

A computer vision project demonstrating handwritten digit classification (MNIST) using a from-scratch CNN library (BareCNN) and a classic LeNet-5 architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages