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.
.
├── .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.
- Python 3.x
- BareCNN library must be accessible in your Python environment.
# 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/BareCNNThe main.py script handles training and prediction.
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.npzThis trains the model for 10 epochs, evaluates it on the test set, and saves the weights.
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.pngMIT License. See the LICENSE file.