This project is about training convolutional neural network model (CNN) for use cases:
- I self-driving vehicle
- II captcha image recognition
You can run project locally or using docker.
- Install PHP 8.1 with dependencies:
php8.1-imagick php8.1-gd php8.1-sqlite3
- Install composer
- Install Rindow OpenBLAS PHP extension
- Install project dependencies:
composer install
- Set
memory_limit = -1
in php.ini
To train and test model run:
bin/cli self-driving-image-classification-cnn-pipeline
or using docker:
docker run --rm rzarno/phpcnn \
self-driving-image-classification-cnn-pipeline
The goal for a trained model is to lead self-driving vehicle to choose proper action (go forward, turn left, turn right) based on image from front camera. Car has to follow track inside created lane.
CNN model is based on Nvidia "DAVE 2" proposed architecture
https://arxiv.org/pdf/1604.07316v1.pdf
model implementation and training was handled thanks to Rindow Neural Networks
https://github.com/rindow/rindow-neuralnetworks
data distribution:
main program is based on chain of responsibility design pattern implemented using league/pipeline and containing stages:
- Import data
- Analyze dataset
- Impute more data based on imported images
- Split data to training and test set
- Preprocess images - scale and flatten
- Build convolutional neural network model from specified layers
- Train model
- Export model
- Evaluate model
Model trained with 42000 images and 20 epochs achieves 72% accuracy.
Results for specific classes: correct predictions 1: 73/102 72% correct predictions 2: 37/57 65% correct predictions 3: 34/42 81%
To train and test model run:
bin/cli captcha-image-classification-cnn-pipeline
or using docker:
docker run --rm rzarno/phpcnn \
captcha-image-classification-cnn-pipeline
The goal for trained model is to recognize 6 characters from captcha images like below.
Captcha can contain any of 28 characters below. Letters are skewed, transformed and rotated. ['6', '2', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'W', 'V', 'X', 'Y', 'Z']
data distribution:
- Import data
- Analyze dataset
- Crop and adjust image, extract single chars
- Split data to training and test set
- Preprocess images - scale and flatten
- Build convolutional neural network model from specified layers
- Train model
- Export model
- Evaluate model
Model trained with 42000 images and 20 epochs achieves 87% accuracy.
Prediction has good accuracy for all 28 classes.