Skip to content

AI app recognizing handwritten digits using TensorFlow and Flask deployment

Notifications You must be signed in to change notification settings

prady00/digreco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DigReco

🚀 Project Overview

DigReco (short for Digits Recognition) is an AI-powered application designed to recognize handwritten digits. It uses TensorFlow for model development and Flask for deployment, the project provides a simple, interactive interface to predict digits written by users.

🚀 Video

This project was presented in a webinar. Here you can find the recorded video for complete walkthrough of project - Link.

🎯 Features

  • AI Model: Built with a Convolutional Neural Network (CNN) using TensorFlow/Keras.
  • Interactive UI: Allows users to upload an image for recognition.
  • Real-Time Prediction: Instant feedback on digit recognition.
  • Scalable Backend: Flask powers the server for easy deployment and API integration.
  • Customizability: Ready for extensions to support additional datasets or recognition tasks.

🛠️ Tech Stack

  • Backend: Flask (Python)
  • AI Framework: TensorFlow/Keras
  • Frontend: HTML/CSS/JavaScript
  • Deployment: Flask Server

📂 Project Structure

DigReco/
│
├───FrontEnd/                    # Contains all frontend-related files
│   │
│   ├── index.html               # Main HTML file that provides the user interface
│   ├── scripts.js               # JavaScript for handling user interactions and API calls
│   └── styles.css               # CSS file for styling the UI
│
├───ModelServing/                # Folder for model deployment and serving
│   │
│   ├── backend.py               # Flask-based backend to handle API requests and serve predictions
│   └── tuned_handwritten_digit_model.h5  # Pre-trained model for handwritten digit recognition
│
├───ModelTraining/               # Folder for training the model
│   │
│   └── training.py              # Script for training the digit recognition model using TensorFlow/Keras
│
└───TestingData/                 # Sample testing images for validating the model
    │
    ├── 0.PNG                    
    ├── 2.PNG                    
    ├── 3.PNG                    
    ├── 5-2.PNG                  
    ├── 6.PNG                    
    ├── 7.PNG                    
    └── 8.PNG                    


🔧 Setup and Installation

Prerequisites

  • Python 3.8 or higher
  • TensorFlow/Keras
  • Flask

Installation Steps

  1. Clone the repository:

    git clone https://github.com/prady00/digreco.git
    cd digreco
  2. Create a virtual environment (optional but recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Training the model (optional, I've added a pretrained model):

    cd ModelTraining
    python training.py

    It will produce a model tuned_handwritten_digit_model.h5 You can move tuned_handwritten_digit_model.h5 to ModelServing folder for deployment or serving

  5. Start the backend:

    cd ModelServing
    python backend.py

    Keep the terminal running. It exposes the model through Flask on port 5000

  6. Start the frontend:

    cd Frontend
    python -m http.server
  7. Access the frontend app: Open http://localhost:8000 in your browser.


🧠 Model Details

  • The model is a Convolutional Neural Network (CNN) trained on the MNIST dataset.
  • Architecture:
    • Input Layer: 28x28 grayscale image
    • 2 Convolutional Layers + MaxPooling
    • Flatten Layer
    • Fully Connected Dense Layers
    • Activation: ReLU, Softmax
  • Output: Predicted digit (0-9) with confidence score.

🖥️ Usage

From the UI

  • Upload digit on the provided UI and click "Predict".
  • Alternatively, upload a .png or .jpg file containing a handwritten digit.

API Integration

Use the Flask API to send images programmatically.

Endpoint:

POST /predict

Request: Send an image as form data under the key file.

Example using cURL:

curl -X POST -F "[email protected]" http://localhost:5000/predict

Response:

{
   "digit": 5,
   "confidence": 0.97
}

🚀 Future Enhancements

  • Support for multi-digit recognition.
  • Integration with other digit datasets (e.g., EMNIST).
  • Deploy to cloud platforms like AWS, Azure, or Heroku.
  • Mobile-friendly UI for seamless usage.

👨‍💻 Contributing

We welcome contributions! Feel free to:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Submit a pull request with improvements or fixes.

📜 License

This project is licensed under the MIT License.


🤝 Contact

For queries or suggestions, reach out at:

About

AI app recognizing handwritten digits using TensorFlow and Flask deployment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published