Skip to content

Arabic math solver (server) is a flask web server that recognizes an image of a mathematical expression in Arabic notation and applies an operation on it like integration, differentiation, etc.

License

Notifications You must be signed in to change notification settings

omarshawky15/ArabicMathSolver-Server

Repository files navigation

Arabic Math Solver - Server Side

OpenCV Flask TensorFlow

is a flask web app which recognizes sent image of an Arabic mathematical expression through characters' segmentation, characters recognition, and parsing them into a mathematical expression then apply an operation on it e.g (solving the roots of polynomial, integration, etc).

Table of Contents

Examples

Expression Image HTML Recognition Output
س ٢+٣*س+٢
(لـو٢(٨)+ظا(٤٥))\(س ٢+√(س+٦))

Getting Started

Prerequisites

  • python >= 3.8.12

Installation (For windows)

  1. Clone the repo

git clone git@github.com:omarshawky15/ArabicMathSolver-Server.git

  1. Create a virtual environment

python -m venv venv

  1. Activate the virtual environment

source venv/Scripts/activate

  1. Install the required packages

pip install -r requirements.txt

Usage

  • To start the local server, run

python app.py

then upload the image to the server and see the html output. (Default operation: solving the roots of polynomial)

  • To use without running the server, uncomment the runLocal() function in app.py, insert the image path, and comment app.run().

Main Components

Segmentation

The image is partitioned into multiple cropped characters by analyzing their contours using OpenCV.

Recognition

Each character is recognized using our trained tensorflow model which consists of the following layers.

Layer (type) Output Shape Param #
(BatchNormalization) (None, 32, 32, 1) 4
(Conv2D) (None, 32, 32, 64) 1664
(Conv2D) (None, 32, 32, 64) 102464
(MaxPooling2D) (None, 16, 16, 64) 0
(Dropout) (None, 16, 16, 64) 0
(Conv2D) (None, 16, 16, 128) 73856
(Conv2D) (None, 16, 16, 128) 147584
(MaxPooling2D) (None, 8, 8, 128) 0
(Dropout) (None, 8, 8, 128) 0
(Flatten) (None, 8192) 0
(Dropout) (None, 8192) 0
(Dense) (None, 256) 2097408
(Dense) (None, 43) 11051

Parsing

Symbols are parsed together to form a mathematical expression where different combinations are handled like fraction, power, square root, ..etc

Output

The chosen operation (integration, differentiation, etc.) is applied on the mathematical expression using SymPy which is a library for symbolic mathematics. Then both the expression and the operation output are translated back to Arabic mathematical notation.

Related Projects

Arabic Math Solver - Android App

License

This application is released under GNU GPLv3 (see LICENSE).

For more details, see the graduation project book.

About

Arabic math solver (server) is a flask web server that recognizes an image of a mathematical expression in Arabic notation and applies an operation on it like integration, differentiation, etc.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages