In this project, we implement an Arabic Font Recognition System. Given an image containing a paragraph written in Arabic, the system is supposed to classify the paragraph into one of four fonts (from 0 to 3).
Font 0 | Font 1 | Font 2 | Font 3 |
---|---|---|---|
Scheherazade New | Marhey | Lemonada | IBM Plex Sans Arabic |
This repository contains code for loading a dataset, preprocessing the images, and training a PyTorch model using a Sequential neural network with 3 linear layers.
-
Data Loading and Splitting:
- Loading the dataset.
- Splitting the dataset into training and validation sets.
-
Image Preprocessing:
- Removing salt and pepper noise using median blur.
- Sharpening the image using filter2d.
- Converting the image to binary.
- Deskewing the image.
- Resizing the image.
-
Feature Extraction:
- Feature extraction is done using Histogram of Oriented Gradients (HOG) and Scale-Invariant Feature Transform (SIFT).
-
Feature Scaling:
- We apply standardization to the extracted features.
-
Dimensionality Reduction:
- Principal Component Analysis (PCA) is applied with n_components = 0.99 to reduce the dimensionality of the features.
-
Model Architecture:
- Input layer processes feature vectors.
- 2 hidden layers learn complex patterns with ReLU activation.
- Output layer generates class probabilities with softmax activation.
-
Model Training:
- The Sequential model is trained on the preprocessed dataset.
-
Model Tuning:
- Hyperparameter tuning is performed on the validation set.
- The best model parameters are saved after tuning.
-
Clone the repository:
git clone https://github.com/ZiaddAhmedd/Arabic-font-recognition-system.git
-
Install dependencies:
pip install -r requirements.txt
-
Run script:
python font_recognition.py
-
Start local server using FastAPI:
python -m uvicorn Deploy:app --reload
For any inquiries, please contact: