Code Monkey home page Code Monkey logo

phpcnn's Introduction

Training Convolutional Neural Network in PHP

This project is about training convolutional neural network model (CNN) for use cases:

  • I self-driving vehicle
  • II captcha image recognition

Setup

You can run project locally or using docker.

Local

  1. Install PHP 8.1 with dependencies: php8.1-imagick php8.1-gd php8.1-sqlite3
  2. Install composer
  3. Install Rindow OpenBLAS PHP extension
  4. Install project dependencies: composer install
  5. Set memory_limit = -1 in php.ini

I self-driving vehicle

Setup

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

About

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.

Project base components

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:

  1. Import data
  2. Analyze dataset
  3. Impute more data based on imported images
  4. Split data to training and test set
  5. Preprocess images - scale and flatten
  6. Build convolutional neural network model from specified layers
  7. Train model
  8. Export model
  9. Evaluate model

Results

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%


II captcha image recognition

Setup

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

About

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:

Pipeline

  1. Import data
  2. Analyze dataset
  3. Crop and adjust image, extract single chars
  4. Split data to training and test set
  5. Preprocess images - scale and flatten
  6. Build convolutional neural network model from specified layers
  7. Train model
  8. Export model
  9. Evaluate model

Results

Model trained with 42000 images and 20 epochs achieves 87% accuracy.

Prediction has good accuracy for all 28 classes.

phpcnn's People

Contributors

rzaru avatar rzarno avatar hoolek77 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.