{"id":29022972,"url":"https://github.com/kamalarnav04/handwrittendigitrecognizer","last_synced_at":"2026-04-14T06:33:41.540Z","repository":{"id":299454867,"uuid":"1003095350","full_name":"kamalarnav04/HandwrittenDigitRecognizer","owner":"kamalarnav04","description":"A neural network-based handwritten digit recognition system built with TensorFlow/Keras that can classify handwritten digits (0-9) from the MNIST dataset with 97.8% validation accuracy.","archived":false,"fork":false,"pushed_at":"2025-06-16T16:16:21.000Z","size":11524,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-26T03:04:33.201Z","etag":null,"topics":["python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamalarnav04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-16T16:03:36.000Z","updated_at":"2025-06-16T16:16:25.000Z","dependencies_parsed_at":"2025-06-16T17:50:22.151Z","dependency_job_id":null,"html_url":"https://github.com/kamalarnav04/HandwrittenDigitRecognizer","commit_stats":null,"previous_names":["kamalarnav04/handwrittendigitrecognizer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kamalarnav04/HandwrittenDigitRecognizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalarnav04%2FHandwrittenDigitRecognizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalarnav04%2FHandwrittenDigitRecognizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalarnav04%2FHandwrittenDigitRecognizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalarnav04%2FHandwrittenDigitRecognizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamalarnav04","download_url":"https://codeload.github.com/kamalarnav04/HandwrittenDigitRecognizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalarnav04%2FHandwrittenDigitRecognizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261990349,"owners_count":23241188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","tensorflow"],"created_at":"2025-06-26T03:04:31.530Z","updated_at":"2026-04-14T06:33:41.510Z","avatar_url":"https://github.com/kamalarnav04.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Handwritten Digit Recognizer 🔢\n\nA neural network-based handwritten digit recognition system built with TensorFlow/Keras that can classify handwritten digits (0-9) from the MNIST dataset with **97.8% validation accuracy**.\n\n![Python](https://img.shields.io/badge/python-v3.8+-blue.svg)\n![TensorFlow](https://img.shields.io/badge/TensorFlow-v2.12+-orange.svg)\n\n## 🎯 Project Overview\n\nThis project implements a feedforward neural network to recognize handwritten digits using the famous MNIST dataset. The model can process both the original MNIST dataset and custom PNG images uploaded by users.\n\n### Key Features\n- **High Accuracy**: Achieves 97.8% validation accuracy\n- **Fast Training**: Trains in under 15 seconds (5 epochs)\n- **Custom Image Support**: Can predict digits from user-uploaded PNG images\n- **Lightweight Architecture**: Simple yet effective 3-layer neural network\n- **Easy to Use**: Interactive prediction interface\n\n## 📊 Model Performance\n\n| Metric | Training | Validation |\n|--------|----------|------------|\n| **Accuracy** | 98.55% | 97.80% |\n| **Loss** | 0.0442 | 0.0854 |\n| **Training Time** | ~12 seconds | - |\n\n### Training Progress\n```\nEpoch 1/5: loss: 0.2573 - accuracy: 0.9249 - val_accuracy: 0.9665\nEpoch 2/5: loss: 0.1086 - accuracy: 0.9663 - val_accuracy: 0.9762\nEpoch 3/5: loss: 0.0766 - accuracy: 0.9763 - val_accuracy: 0.9745\nEpoch 4/5: loss: 0.0572 - accuracy: 0.9816 - val_accuracy: 0.9760\nEpoch 5/5: loss: 0.0442 - accuracy: 0.9855 - val_accuracy: 0.9780\n```\n\n## 🏗️ Model Architecture\n\nThe neural network consists of:\n\n```\nInput Layer:     784 neurons (28×28 flattened image)\nHidden Layer 1:  128 neurons (ReLU activation)\nHidden Layer 2:  64 neurons (ReLU activation)  \nOutput Layer:    10 neurons (Softmax activation)\n```\n\n**Total Parameters**: ~101,770 trainable parameters\n\n### Architecture Highlights\n- **Activation Functions**: ReLU for hidden layers, Softmax for output\n- **Optimizer**: Adam with learning rate 0.001\n- **Loss Function**: Sparse Categorical Crossentropy\n- **Regularization**: 10% validation split for monitoring\n\n## 📁 Dataset\n\nThe project uses the **MNIST Dataset** with the following files:\n- `train-images-idx3-ubyte`: 60,000 training images (28×28 pixels)\n- `train-labels-idx1-ubyte`: 60,000 training labels\n- `t10k-images-idx3-ubyte`: 10,000 test images\n- `t10k-labels-idx1-ubyte`: 10,000 test labels\n\n### Data Preprocessing\n1. **Normalization**: Pixel values scaled from [0, 255] to [0, 1]\n2. **Reshaping**: Images flattened from 28×28 to 784-dimensional vectors\n3. **Type Conversion**: Images converted to float32 for efficient computation\n\n## 📝 Usage\n\n### Training the Model\nThe model trains automatically when you run all cells in the notebook. Training takes approximately 12 seconds on modern hardware.\n\n### Making Predictions on Custom Images\n```python\n# Example usage for custom PNG images\nfile_path = \"path/to/your/digit_image.png\"\npredicted_class, confidence = predict_from_png(file_path)\n\nprint(f\"Predicted digit: {predicted_class}\")\nprint(f\"Confidence: {confidence:.4f}\")\n```\n\n### Image Requirements for Custom Predictions\n- **Format**: PNG\n- **Content**: Single handwritten digit on light background\n- **Automatic Processing**: The function handles resizing to 28×28 and grayscale conversion\n\n## 🔬 Technical Details\n\n### Data Loading\nCustom functions to read MNIST's binary format:\n- `load_images()`: Reads image data from idx3-ubyte files\n- `load_labels()`: Reads label data from idx1-ubyte files\n\n### Model Configuration\n```python\nmodel = tf.keras.Sequential([\n    layers.Dense(128, activation='relu', input_shape=(784,)),\n    layers.Dense(64, activation='relu'),\n    layers.Dense(10, activation='softmax') \n])\n\nmodel.compile(\n    optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3),\n    loss='sparse_categorical_crossentropy',\n    metrics=['accuracy']\n)\n```\n\n### Image Preprocessing Pipeline\n```python\ndef predict_from_png(file_path):\n    img = Image.open(file_path).convert('L')  # Grayscale\n    img = img.resize((28, 28))                # Resize to MNIST dimensions\n    img_array = np.array(img) / 255.0         # Normalize\n    img_array = img_array.reshape(1, 784)     # Flatten\n    return model.predict(img_array)\n```\n\n## 📈 Results Analysis\n\n### Strengths\n- ✅ **High Accuracy**: 97.8% validation accuracy\n- ✅ **Fast Training**: Converges quickly in 5 epochs\n- ✅ **Robust Performance**: Consistent across training and validation\n- ✅ **Practical Application**: Works with real-world PNG images\n\n## 🛠️ File Structure\n```\nHandwrittenDigitRecognizer/\n├── model.ipynb                    # Main Jupyter notebook\n├── README.md                      # This file\n├── train-images-idx3-ubyte        # Training images\n├── train-labels-idx1-ubyte        # Training labels  \n├── t10k-images-idx3-ubyte         # Test images\n├── t10k-labels-idx1-ubyte         # Test labels\n```\n\n## 📚 References\n\n- [MNIST Database](http://yann.lecun.com/exdb/mnist/)\n- [TensorFlow Documentation](https://www.tensorflow.org/)\n- [Keras Sequential Model Guide](https://keras.io/guides/sequential_model/)\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamalarnav04%2Fhandwrittendigitrecognizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamalarnav04%2Fhandwrittendigitrecognizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamalarnav04%2Fhandwrittendigitrecognizer/lists"}