In this project i'm using the php fann connector for the FANN library to develop an OCR based on the MNIST dataset.
sudo apt install libfann-dev libfann2
pecl install fann # get the dll here http://pecl.php.net/package/fann if you are using windows
git clone https://github.com/mauri870/php-fann-mnist
cd php-fann-mnist
You can also use a docker container to try the project:
docker run -it php:latest bash
First you need to download the mnist dataset, for that run the following commands:
mkdir -p data
NAMES="train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte"
for n in $NAMES; do
echo "Downloading $n..."
wget -qO- http://yann.lecun.com/exdb/mnist/$n.gz | gunzip -c > data/$n
done
Next generate the train/test and validation files for FANN
php preprocess.php
php train.php
Since FANN rely only on cpu computations, you can expect a training time of ~40 minutes on an octa core processor
php test.php