This is a beginner-friendly project where I built a simple digit recognition app using a neural network trained on the MNIST dataset. The goal was to understand the end-to-end workflow of a Machine Learning project — from model creation to deployment in a simple graphical interface.
🧠 This was my first Machine Learning project!
You’ll notice I included lots of comments in the code to help myself understand each step.
The purpose was educational — to learn deeply, not just make it work. 😊
- You draw a number (0–9) in a canvas with your mouse.
- The image is preprocessed and passed to a trained PyTorch model.
- The model predicts which number it thinks you drew.
- The result is displayed instantly!
The model is a simple feedforward neural network implemented with PyTorch:
- Input layer: 28×28 = 784 pixels (flattened)
- Hidden layer: 15 neurons, ReLU activation
- Output layer: 10 neurons (digits 0–9), with raw scores (logits)
class NeuralNetwork(nn.Module):
def __init__(self):
super().__init__()
self.flatten = nn.Flatten()
self.network = nn.Sequential(
nn.Linear(28*28, 15),
nn.ReLU(),
nn.Linear(15, 10)
)
def forward(self, x):
x = self.flatten(x)
return self.network(x)The model was trained on the MNIST dataset.
- Built with Tkinter (Python's standard GUI library).
- You can draw directly on a canvas.
- The app converts your drawing into a 28×28 grayscale image, normalizes it, and passes it to the model.
model.py: The neural network definition.training.py: Script to train the model.app.py: The graphical user interface.model.pth: Saved PyTorch model (trained weights).
Install dependencies with:
pip install -r requirements.txt
tkintercomes pre-installed with Python (especially on Windows). No need to install it with pip.
-
Train the model (or use the included
model.pth):python training.py
-
Run the app:
python app.py
This project is licensed under the MIT License – see the LICENSE file for details.
Thank you for checking out my project!
This was an exciting start in my Machine Learning journey — feel free to reach out if you have suggestions or feedback 😊💖
