README
Font Recognition System โ "The Librarian from Alexandria"
- In order to execute the code, install a virtual environment and the packages in the requirements.txt file.
- pip install virtualenv
- virtualenv venv
- source venv/Scripts/activate
- pip install -r requirements
๐ฅ Team Members
- Corrado Valeri
- Michele Baldo
๐ Introduction
This project aims to create a deep learning-based font classification system for historical documents. The system processes a set of scanned text images and classifies them into one of 11 ancient font categories. The ultimate goal is to contribute a robust model that can aid in the automatic digitization and indexing of historical archives using machine learning.
๐งช Methods
๐ง Design Overview
The approach is divided into three core modules: 1. Image Preprocessing โ Clean and enhance the scanned images. 2. Data Augmentation โ Expand the dataset through synthetic variations (Due to computing limitation we only saved the last tranfomration not accomplishing the real goal of dataaugmentation but still giving varaitions that helped the training phase). 3. Model Training โ Utilize a pre-trained ResNet50 model based on ImageNet Dataset for classification.
๐ Environment
- Python 3.10+
- PyTorch, torchvision, pandas, scikit-learn, seaborn
- Compatible with both GPU and CPU environments
- Required setup:
condaenvironment orrequirements.txtlisting all dependencies
๐ Preprocessing Pipeline
Each scanned image is:
- Converted to grayscale
- Binarized via a threshold
- Denoised using a Median filter
- Saved in immagini_formattate
๐งฌ Data Augmentation
For every denoised image:
- Affine transformations (translation, flip, brightness/contrast jitter)
- Gaussian noise addition
- Elastic distortion applied
- Saved in immagini_reteneurale
This ensures better generalization and robustness of the trained model.
๐งซ Experimental Design
๐ฏ Purpose
To train a classifier capable of distinguishing 11 distinct font styles from historical scanned images.
๐ Baseline
No pretrained classifier was used as a benchmark; instead, the performance of the ResNet50 fine-tuned head was evaluated directly.
๐งฎ Evaluation Metrics
- Accuracy
- Precision
- Recall
- F1-Score
Metrics were computed per epoch for both training and testing sets.
๐ Results
๐ Main Findings
- ResNet50 achieved high classification performance with accuracy surpassing 90% on the test set.
- Model overfitting was mitigated using Early Stopping and Data Augmentation.
- Precision/Recall/F1-Score metrics were stable across epochs.
๐ Example Figures and Tables
โ Training/Test Accuracy per Epoch
๐ Precision / Recall / F1 per Epoch
๐ Confusion Matrix
Note: All visualizations are generated programmatically and saved in
model_results/.
๐งพ Conclusions
The model demonstrates the feasibility of using deep learning techniques to classify historical fonts with strong generalization across diverse document structures. The data augmentation techniques were pivotal in compensating for the relatively small dataset.
๐ฎ Future Work
In the repository, there is an additional script that we were unable to test due to time constraints and limited computational resources. This alternative version includes all the data transformations and integrates the validation set into the model analysis for a more comprehensive evaluation.
๐ Notebook Structure
main.ipynb includes:
- Detailed textual explanations before each code cell
- Comments on model design choices
- Clear documentation of all outputs, including visual results and metrics
10 files
file contents open where the seller allows a preview; the rest is what you are buying
model_results/4
- README.md4 KB
- TheLibFromAlexandria.pdf11.2 MB
- main.ipynb265 KB
- main_not_tested.ipynb266 KB
- pages.csv57 KB
- requirements.txt84 B