{"id":23084741,"url":"https://github.com/asrot0/handdrawndigitai","last_synced_at":"2026-04-29T08:33:22.262Z","repository":{"id":263998542,"uuid":"892037561","full_name":"asRot0/HandDrawnDigitAI","owner":"asRot0","description":"🚀AI-powered app for handwritten digit recognition with an interactive GUI built 🎨 using CNN and CustomTkinter.","archived":false,"fork":false,"pushed_at":"2025-03-03T09:16:45.000Z","size":8010,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T15:12:59.828Z","etag":null,"topics":["artificial-intelligence","cnn","deep-learning","digit-recognition","interactive-drawing","machine-learning","mnist","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","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/asRot0.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}},"created_at":"2024-11-21T12:00:33.000Z","updated_at":"2025-03-03T09:16:48.000Z","dependencies_parsed_at":"2024-12-16T16:43:36.652Z","dependency_job_id":"8da2f98d-6edf-45f2-be1c-f778387b48be","html_url":"https://github.com/asRot0/HandDrawnDigitAI","commit_stats":null,"previous_names":["asrot0/handdrawndigitai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asRot0%2FHandDrawnDigitAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asRot0%2FHandDrawnDigitAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asRot0%2FHandDrawnDigitAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asRot0%2FHandDrawnDigitAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asRot0","download_url":"https://codeload.github.com/asRot0/HandDrawnDigitAI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247024152,"owners_count":20870940,"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":["artificial-intelligence","cnn","deep-learning","digit-recognition","interactive-drawing","machine-learning","mnist","tensorflow"],"created_at":"2024-12-16T16:43:31.608Z","updated_at":"2026-04-29T08:33:22.257Z","avatar_url":"https://github.com/asRot0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HandDrawnDigitAI\n\nWelcome to **HandDrawnDigitAI** – an intuitive app for recognizing hand-drawn digits! Powered by **CustomTkinter**, a pre-trained **Convolutional Neural Network (CNN)**, and a user-friendly **GUI**, this project brings machine learning right to your fingertips. Draw digits, recognize them instantly, and enjoy the seamless experience!\n\n### 🌸 *`BlackPink`* Theme\n![themes](themes/pic1.png)\n\n## Features\n\n- **Interactive Drawing Canvas**  \n  Use the mouse to draw digits directly on the canvas.\n\n- **AI-Powered Digit Recognition**  \n  Recognize digits (0-9) using a **pre-trained CNN model** trained on the **MNIST dataset**.\n\n- **Dynamic Themes**  \n  Choose from multiple visually appealing themes:  \n  🔵 *Oceanic* | 🌙 *Dark Mode* | 🎨 *Vibrant* | 🖤 *Corporate* | 🌸 *Pink Black*\n\n- **Modular Codebase**  \n  Clean and organized project structure for easy navigation.\n\n| 🌙 Dark Mode | 🔵 Oceanic | 🌸 Pink Black |\n|:------------:|:----------:|:-------------:|\n| ![Dark Mode](https://via.placeholder.com/200/333333/00FF00?text=Dark+Mode) | ![Oceanic](https://via.placeholder.com/200/E0FFFF/1E90FF?text=Oceanic) | ![Pink Black](https://via.placeholder.com/200/FFC0CB/FF007F?text=Pink+Black) |\n\n### How It Works\n\n1. **Draw a digit** on the canvas.  \n2. **Press the \"Predict\" button**, and the model will recognize the digit.  \n3. If the prediction isn't clear, **adjust and re-draw** on the canvas!  \n4. Use the **\"Clear Canvas\" button** to start over.\n\n## Requirements\n\nMake sure you have the following dependencies installed before running the app:\n\n```plaintext\ntensorflow==2.10.0\ncustomtkinter==5.1.2\npillow==9.2.0\nnumpy==1.23.0\nopencv-python==4.6.0\n```\n\n#### Install them using:\n```\npip install -r requirements.txt\n```\n\n## Running the Application\nFollow these steps to get started:\n\n1. Clone the repository:\n\n```\ngit clone https://github.com/asRot0/HandDrawnDigitAI.git\ncd HandDrawnDigitAI\n```\n\n2. Install the required dependencies:\n\n```\npip install -r requirements.txt\n```\n3. Run the app:\n\n```\npython run.py\n```\n4. Draw digits and enjoy the magic!\n\n---\n\n## Key Math Concepts for CNN \u0026 MNIST\n\nHere are some important mathematical formulas used in this project\n\n### **Convolution Operation (Feature Extraction in CNN)**\nConvolutional layers apply filters to extract features from input images.\n\n$$\n\\LARGE O(i, j) = \\sum_m \\sum_n I(i+m, j+n) \\cdot K(m, n)\n$$\n\n- $`O(i, j)`$ → Output feature map at position $(i, j)$.  \n- $`I(i+m, j+n)`$ → Input image pixels affected by the filter.  \n- $`K(m, n)`$ → Kernel (`filter`) values applied to the input.  \n\n**Why Add?**\n- Represents how a **filter (kernel) slides over an image** to extract meaningful features.\n- Core operation in **Convolutional Neural Networks (CNNs)**.\n\n### **ReLU Activation Function (Hidden Layers)**\nReLU introduces non-linearity to the model by keeping only positive values.\n\n$$\n\\LARGE \\text{ReLU}(x) = \\max(0, x)\n$$\n\n- $`x`$ → Input value to the activation function.  \n\n**Why Add?**\n- Helps **prevent vanishing gradients**.\n- Improves CNN’s ability to learn complex patterns.\n\n### **Max Pooling (Dimensionality Reduction)**\nMax pooling reduces the spatial size of feature maps while preserving key information.\n\n$$\n\\LARGE P(i, j) = \\max_{(m,n) \\in R} F(i+m, j+n)\n$$\n\n- $`P(i, j)`$ → Pooled output value at position $(i, j)$.  \n- $`F(i+m, j+n)`$ → Input feature map values in the pooling region.  \n- $`R`$ → Pooling region (e.g., 2×2 or 3×3 window).  \n\n**Why Add?**\n- Reduces computation and prevents **overfitting**.\n- Keeps **dominant features** while discarding unnecessary details.\n\n### **Softmax Function (Final Layer for Classification)**\nThe softmax function converts model outputs into probability distributions.\n\n$$\n\\LARGE \\text{Softmax}(z_i) = \\frac{e^{z_i}}{\\sum_{j=1}^{n} e^{z_j}}\n$$\n\n- $`z_i`$ → Raw score (logit) for class $( i )$.  \n- $`e^{z_i}`$ → Exponential of the logit, ensuring positive values.  \n- $`\\sum_{j=1}^{n} e^{z_j}`$ → Sum of exponentials across all $( n )$ classes (normalization factor).  \n\n**Why Add?**\n- Softmax assigns **probabilities to digit classes (0-9)**.\n- Ensures outputs sum up to **1**, making it interpretable.\n\n### **Cross-Entropy Loss (Training the CNN)**\nCross-entropy measures the difference between predicted and actual labels.\n\n$$\n\\LARGE \\mathcal{L} = -\\sum_{i=1}^{n} y_i \\log(\\hat{y_i})\n$$\n\n- $`\\mathcal{L}`$ → Cross-entropy loss value.  \n- $`y_i`$ → Actual label (ground truth) for class $( i )$ (1 for correct class, 0 otherwise).  \n- $`\\hat{y_i}`$ → Predicted probability from the `softmax` function.  \n\n**Why Add?**\n- Penalizes incorrect predictions by increasing the loss.\n- Common **loss function** for **multi-class classification**.\n\n### **Adam Optimizer (Gradient Descent for CNN Training)**\nAdam adjusts learning rates based on gradients to optimize CNN performance.\n\n$$\n\\LARGE \\theta_{t+1} = \\theta_t - \\frac{\\eta}{\\sqrt{v_t} + \\epsilon} m_t\n$$\n\n- $`\\theta_t`$ → Model parameters at step $( t )$.  \n- $`m_t`$ → First moment estimate (mean of gradients).  \n- $`v_t`$ → Second moment estimate (variance of gradients).  \n- $`\\eta`$ → Learning rate (step size).  \n- $`\\epsilon`$ → Small constant to avoid division by zero.  \n\n**Why Add?**\n- Used as the **optimizer** in this project (`optimizer='adam'`).\n- Combines **momentum \u0026 adaptive learning rates** for faster convergence.\n\nThese mathematical concepts power the **CNN architecture** used in this project. They help in **feature extraction, classification, optimization, and learning** to recognize hand-drawn digits **efficiently and accurately**.  \n\n---\n\n## Contributors\n- Asif Ahmed – [GitHub](https://github.com/asRot0/)  \nCreator and Maintainer\n\nWant to contribute? Feel free to fork the repository and open a pull request!\n\n## Support\nIf you find this project helpful, consider giving it a ⭐ on [GitHub](https://github.com/asRot0/HandDrawnDigitAI) and sharing it with others!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasrot0%2Fhanddrawndigitai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasrot0%2Fhanddrawndigitai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasrot0%2Fhanddrawndigitai/lists"}