{"id":25486617,"url":"https://github.com/hakanozger/handwritten-digit-recognizer","last_synced_at":"2026-04-09T12:07:03.066Z","repository":{"id":277437789,"uuid":"932427002","full_name":"hakanozger/handwritten-digit-recognizer","owner":"hakanozger","description":"A deep learning-based handwritten digit classification system using Flask (backend) and React (frontend). The model is trained on the MNIST dataset with CNN and data augmentation for improved accuracy.","archived":false,"fork":false,"pushed_at":"2025-02-13T22:55:50.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T23:33:19.753Z","etag":null,"topics":["ai","deep-learning","docker","docker-compose","flask","image-classification","machine-learning","python","tensorflow"],"latest_commit_sha":null,"homepage":"https://hakanozger.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hakanozger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-02-13T22:28:18.000Z","updated_at":"2025-02-13T23:00:46.000Z","dependencies_parsed_at":"2025-02-13T23:33:22.670Z","dependency_job_id":"178ce048-c9b8-480d-90d7-1e0607f00537","html_url":"https://github.com/hakanozger/handwritten-digit-recognizer","commit_stats":null,"previous_names":["hakanozger/handwritten-digit-recognizer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakanozger%2Fhandwritten-digit-recognizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakanozger%2Fhandwritten-digit-recognizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakanozger%2Fhandwritten-digit-recognizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hakanozger%2Fhandwritten-digit-recognizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hakanozger","download_url":"https://codeload.github.com/hakanozger/handwritten-digit-recognizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239533064,"owners_count":19654617,"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":["ai","deep-learning","docker","docker-compose","flask","image-classification","machine-learning","python","tensorflow"],"created_at":"2025-02-18T19:21:25.305Z","updated_at":"2025-12-30T21:34:36.596Z","avatar_url":"https://github.com/hakanozger.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Handwritten Digit Recognizer\n\n## Overview\nThis project is a **handwritten digit recognition system** built using **Flask (backend) and React (frontend)**. It uses a **Convolutional Neural Network (CNN) trained on the MNIST dataset** to classify handwritten digits (0-9). The system is containerized with **Docker and Docker Compose**, making it easy to deploy with a single command.\n\n## Features\n- 🧠 **Deep Learning Model** - Uses an improved CNN model trained on the MNIST dataset.\n- 📸 **Image Upload Support** - Users can upload handwritten digit images for recognition.\n- 🌐 **Web Interface** - Built with React for an interactive UI.\n- 🚀 **REST API** - Flask backend exposes an API for image classification.\n- 📦 **Containerized with Docker** - Runs seamlessly with **Docker Compose**.\n- 🎯 **Data Augmentation** - Enhances model accuracy on real-world images.\n\n---\n\n## Project Structure\n```\nhandwritten-digit-recognizer/\n│── backend/                         # Flask API \u0026 Model\n│   ├── flask_api.py                 # Flask API for predictions\n│   ├── model_trainer.py             # Train the MNIST model (runs inside container)\n│   ├── model/                        # Model directory\n│   │   ├── mnist_model.h5            # Trained model\n│   ├── uploads/                      # Stores uploaded images\n│   ├── requirements.txt              # Python dependencies\n│   ├── Dockerfile                    # Docker config for Flask \u0026 Model Training\n│── frontend/                         # React UI\n│   ├── src/\n│   │   ├── App.js                    # Main React component\n│   │   ├── ImageUploader.js           # Image Upload Component\n│   │   ├── index.js                   # React Entry Point\n│   │   ├── styles.css                 # Styling\n│   ├── public/\n│   │   ├── index.html                 # Main HTML file\n│   ├── package.json                   # React dependencies\n│   ├── Dockerfile                      # Docker config for React\n│── docker-compose.yml                  # Docker Compose for multi-container setup\n│── README.md                           # Project Documentation\n```\n\n---\n\n## Installation \u0026 Setup\n\n### **1️⃣ Prerequisites**\nMake sure you have:\n- **Docker** installed → [Install Docker](https://docs.docker.com/get-docker/)\n- **Node.js \u0026 npm** (for frontend development) → [Download Node.js](https://nodejs.org/)\n\n### **2️⃣ Clone the Repository**\n```bash\ngit clone https://github.com/your-repo/handwritten-digit-recognizer.git\ncd handwritten-digit-recognizer\n```\n\n### **3️⃣ Build and Start the Containers**\n```bash\ndocker compose up --build\n```\nThis will:\n✅ **Train the model (if not already trained)**\n✅ **Start the Flask API** on `http://localhost:5001`\n✅ **Start the React UI** on `http://localhost:3000`\n\n### **4️⃣ Stop the Containers**\nTo stop all running services:\n```bash\ndocker compose down\n```\n\n---\n\n## API Endpoints\n### **1️⃣ Check API Status**\n```bash\nGET http://localhost:5001/\n```\n**Response:**\n```json\n{ \"message\": \"Welcome to the Handwritten Digit Recognizer API!\" }\n```\n\n### **2️⃣ Predict a Digit**\nUpload a handwritten digit image:\n```bash\ncurl -X POST -F \"file=@digit.png\" http://localhost:5001/predict\n```\n**Response:**\n```json\n{ \"predicted_digit\": 3 }\n```\n\n---\n\n## Web Interface (React Frontend)\nOnce running, visit:\n```\nhttp://localhost:3000\n```\n✅ Upload an image of a handwritten digit\n✅ Click **Predict** to get the result\n✅ View the predicted digit instantly\n\n---\n\n## Model Training\nThe model is trained using an **improved CNN** with **data augmentation** to handle real-world handwriting variations.\n\n### **Training Script** (`backend/model_trainer.py`)\n- Uses **three convolutional layers** with **Batch Normalization**\n- **Dropout layers** added to prevent overfitting\n- **Data Augmentation** (rotation, zoom, shift) applied\n- Trained using the **MNIST dataset**\n\nTo manually re-train the model:\n```bash\ndocker compose run backend python model_trainer.py\n```\nThis will re-train and save the model to:\n```\nbackend/model/mnist_model.h5\n```\n\n---\n\n## Deployment\nWant to deploy this project?\n\n### **1️⃣ Deploy with Docker on a Remote Server**\nOn your **remote server (AWS, GCP, DigitalOcean, etc.)**:\n```bash\ngit clone https://github.com/your-repo/handwritten-digit-recognizer.git\ncd handwritten-digit-recognizer\ndocker compose up --build -d\n```\n\n### **2️⃣ Deploy to Render, Vercel, or Heroku**\n- **Backend:** Use Render, AWS Lambda, or Heroku for Flask API\n- **Frontend:** Use Vercel or Netlify for React UI\n\n---\n\n## Troubleshooting\n### **1️⃣ Flask API Not Starting?**\nCheck if model exists:\n```bash\nls backend/model/\n```\nIf missing, re-train it:\n```bash\ndocker compose run backend python model_trainer.py\n```\n\n### **2️⃣ React App Not Loading?**\nTry clearing cache:\n```bash\ncd frontend\nrm -rf node_modules package-lock.json\ndocker compose up --build\n```\n\n---\n\n## License\nThis project is licensed under the **MIT License**.\n\n---\n\n## 👨‍💻 Contributing\nGot improvements? Feel free to fork and submit a PR!\n```bash\ngit clone https://github.com/your-repo/handwritten-digit-recognizer.git\ncd handwritten-digit-recognizer\n```\n\n---\n\n## 🌟 Credits\nBuilt by Hakan Özger 🚀\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakanozger%2Fhandwritten-digit-recognizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakanozger%2Fhandwritten-digit-recognizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakanozger%2Fhandwritten-digit-recognizer/lists"}