Machine Learning with OpenCV, Keras & ImageNet

Reference: http://www.pyimagesearch.com/2016/08/10/imagenet-classification-with-python-and-keras/
François Chollet pushed three Keras models (VGG16, VGG19, and ResNet50) online — these networks are pre-trained on the ImageNet dataset, meaning that they can recognize 1,000 common object classes out-of-the-box.
we can now easily apply VGG16, VGG19, and ResNet50 using Keras and Python to our own applications.
ImageNet is actually a project aimed at labeling and categorizing images into almost 22,000 categories based on a defined set of words and phrases. At the time of this writing, there are over 14 million images in the ImageNet project.

  1. Install keras and tensorflow backend
    list the package needed
  2. Clone the deep-learning-models repository
    Then, to gain access to VGG16, VGG19, and the ResNet50 architectures and pre-trained weights, you need to clone the deep-learning-models repository from GitHub:

    Then go into the dir ‘deep-learning-models’

    Notice how we have four Python files. The resnet50.py , vgg16.py , and vgg19.py  files correspond to their respective network architecture definitions.
    The imagenet_utils  file, as the name suggests, contains a couple helper functions that allow us to prepare images for classification as well as obtain the final class label predictions from the network.
  3. Write some Python code to classify image contents utilizing Convolutional Neural Networks (CNNs) pre-trained on the ImageNet dataset.
    To start, open up a new file, name it ‘test_imagenet.py’ , and insert the following code:

     
  4. Run the python script ‘test_imagenet.py’.
    NOTE: FOR THE FIRST TIME IT’S VERY SLOW BECAUSE IT DOWNLOADED VGG16 WEIGHT FROM INTERNET (~500MB)

    I GOT AN ERROR AT ‘(inID, label) = decode_predictions(preds)[0]’
    SOLUTION: COMMENT LINE #42 in ‘test_imagenet.py’ AND ADD TWO NEW LINES LIKE THIS:

    RUN AGAIN

    SUCCESS! IT CAN RECOGNIZED A DOG ‘BEAGLE’. HERE IS THE RESULTNOTE: The last error ‘NoneType’ not related with keras. TAKE CARE OF IT LATER (SOLUTION READ: http://www.pyimagesearch.com/2016/12/26/opencv-resolving-nonetype-errors/)
    TRY ANOTHER EXAMPLE:

    NOTE: The downloaded dataset would be stored in /.keras/models/ directory. the dataset filename is ‘vgg16_weights_tf_dim_ordering_tf_kernels.h5’ and the labeled index filename is ‘imagenet_class_index.json’.
  5. MORE TEST
    I have some test for recognizing fish on some pictures. I put three samples in ‘images’ directory (/deep-learning-models/images). BUT NONE OF THEM SHOW THE CORRECT RESULT. HERE ARE THE RESULTRECOGNIZED AS ‘tench’ ???
    RECOGNIZED AS ‘electric_ray’ ???
    RECOGNIZED AS ‘hermit_crab’ ???
    I THINK I NEED TO TRAIN THESE SAMPLES FIRST BEFORE IT READY TO BE RECOGNIZED

Upgrade CUDA Toolkit 7.5 to 8.0 & cuDNN v5.1 On Ubuntu 14.04

Reference: http://dhaneshr.net/2016/11/09/upgrading-to-cuda-8-0-on-ubuntu-16-04/
https://developer.nvidia.com/cuda-downloads
https://developer.nvidia.com/rdp/cudnn-download
http://www.pyimagesearch.com/2016/07/04/how-to-install-cuda-toolkit-and-cudnn-for-deep-learning/

The NVIDIA CUDA Toolkit: A development environment for building GPU-accelerated applications. This toolkit includes a compiler specifically designed for NVIDIA GPUs and associated math libraries + optimization routines.
The cuDNN library: A GPU-accelerated library of primitives for deep neural networks. Using the cuDNN package, you can increase training speeds by upwards of 44%, with over 6x speedups in Torch and Caffe.

Currently My system Ubuntu 14.04 installed CUDA toolkit 7.5

Now I want to upgrade it to CUDA toolkit 8.0:

  1. Download the .deb file of CUDA Toolkit 8 (I prefer local here to make the installation smooth) from https://developer.nvidia.com/cuda-downloads.
    I need to select the correct file according to my systemThe file (https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb) is BIG (1.9 GB)!!! IT TOOK ALMOST ONE HOUR TO COMPLETE THE DOWNLOADED FILE
  2. Download cuDNN (NVIDIA CUDA Deep Neural Network library) from https://developer.nvidia.com/rdp/cudnn-download (You need to be a member first)Download the ‘cuDNN v5.1 Library for Linux’ (https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/cudnn-8.0-linux-x64-v5.1-tgz). File size is just 98MB.
  3. Remove CUDA 7.5 package first (NO???)
    This is not working ‘sudo apt-get remove nvidia-cuda-toolkit’

    This is also no make sense ‘sudo apt-get purge cuda-7.5’

    HOW THIS ‘purge’ ONLY REMOVE 16,4kB DATA???
  4. Install the .deb file (THIS INSTALLATION WOULD NOT REMOVE THE OLDER 7.5 VERSION. IT’D BE INSTALLED SIDE BY SIDE)
    Then ‘sudo apt-get update’
    Then

    OK. THEN RESTART YOUR COMPUTER TO SEE ANY WRONG HAPPENED!
  5. The CUDA toolkit 8 is installed in /usr/local/cuda-8.0 (next to ‘cuda-7.5’ and the symlink ‘cuda’)Then we need to modify the environment variables:

    Modify this line

    to

    Save and Close. Then make sure the system use the new changes

    Read also: https://devtalk.nvidia.com/default/topic/971478/installing-cuda-7-5-next-to-cuda-8-0-on-ubuntu-14-04-so-i-can-keep-using-zed-driver-v1-1-0-/
  6. Check CUDA version and the driver


    Now I already use CUDA Toolkit 8.0. I CAN CHANGE ‘.bashrc’ TO BACK TO THE 7.5 VERSION IF IT’S NEEDED!

TRY THE CUDA 8.0 SAMPLES:

  1. Copy the samples into /home/teddy/Documents/

    the samples directory in /home/teddy/Documents/NVIDIA_CUDA-8.0_Samples/
  2. Go into the samples directory
  3. Go into the deviceQuery directory THEN make:


     
  4. run the deviceQuery script to test if we can communicate with the GPU:

     
  5. Go into the bandwidthTest (/NVIDIA_CUDA-8.0_Samples/1_Utilities/bandwidthTest) directory THEN make:

     
  6. run bandwidthTest:

     

INSTALL cuDNN:
Installing cuDNN is quite simple — all we need to do is extract the .tgz file then copy the files in the lib64  and include directories to their appropriate locations on our machine:

Check cuDNN version (http://stackoverflow.com/questions/31326015/how-to-verify-cudnn-installation):

 

Installation of OpenCV, Keras and Tensorflow On Ubuntu 14.04

Reference: http://www.pyimagesearch.com/2016/11/14/installing-keras-with-tensorflow-backend/
step-by-step instructions to install Keras using a TensorFlow backend for machine learning.

Keras is simply a wrapper around more complex numerical computation engines such as TensorFlow and Theano.

When it comes to Keras you have two choices for a backend engine — either TensorFlow or Theano. Theano is older than TensorFlow and was originally the only choice when selecting a backend for Keras.

So why might you want to use TensorFlow over Theano?

The short version is that TensorFlow is extremely flexible, allowing you to deploy network computation to multiple CPUs, GPUs, servers, or even mobile systems without having to change a single line of code.

This makes TensorFlow an excellent choice for training distributed deep learning networks in an architecture agnostic way, something that Theano does not (currently) provide.

Installation:

  1. Use Python virtual environments.

    You can quit the virtualenv with command ‘deactivate’

    And go back the virtualenv with command ‘workon opencv_keras_tf’

    Check python version:

     
  2. Install TensorFlow
    NOTE: Read this about CUDA compute capability : http://stackoverflow.com/questions/10961476/what-are-the-differences-between-cuda-compute-capabilities
    IT SEEMS DEPEND ON THE HARDWARE! NOTHING CAN DO TO IMPROVE THE COMPUTE CAPABILITY!
    AFTER READING THIS https://www.tensorflow.org/versions/r0.10/get_started/os_setup#installing_from_sources AND http://stackoverflow.com/questions/38542763/how-can-i-make-tensorflow-run-on-a-gpu-with-capability-2-0, I GOT SAD NEWS THAT
    In order to build or run TensorFlow with GPU support, both NVIDIA’s Cuda Toolkit (>= 7.0) and cuDNN (>= v3) need to be installed.
    TensorFlow GPU support requires having a GPU card with NVidia Compute Capability >= 3.0.
    SO MY GPU GeForce GT 520M THAT ONLY HAS CUDA COMPUTE CAPABILITY 2.1 (REF: https://en.wikipedia.org/wiki/CUDA) CAN’T BE USED FOR TENSORFLOW!!!I ONLY CAN USE CPU!!!To install TensorFlow, refer to this page: https://www.tensorflow.org/versions/r0.11/get_started/os_setup.
    Currently I have CUDA 7.5 toolkit installed

    The tensorflow page need CUDA toolkit 8.0 and CuDNN v5. I already installed them. I go to ‘Pip installation’ and choose this binary option:

    SO let’s begin:

    Install TensorFlow:

    Test the installation

     
  3. Install Keras
    Install a few Python dependencies:
    Install numpy scify

    Install scikit-learn

    Install pillow

    Install h5py

    Install keras

    Then run ‘import keras’ in python console to create keras.json file (http://stackoverflow.com/questions/40310035/how-to-change-keras-backend-wheres-the-json-file)

    keras.json file would be created in ~/.keras/ (~/.keras/keras.json file)

    Specifically, you’ll want to ensure that image_dim_ordering  is set to tf  (indicating that the TensorFlow image dimension ordering is used rather than th  for Theano).

    You’ll also want to ensure that the backend  is properly set to tensorflow  (rather thantheano ).

  4. Symlink with OpenCV
    My opencv binding file for python 3 is in /usr/local/lib/python3.4/site-packages/cv2.cpython-34m.so. I need to symlink it with the virtualenv ‘opencv_keras_tf’ like this:
    Go into this directory:

    Then symlink it (HERE I CHANGE THE FILE TO ‘cv2.so’)

    Test it

    OK. NO ERROR

Joomla!: Looking for an experienced back end developer for ongoing projects

urlhttps://www.upwork.com/jobs/_~013b998cbfc2e13d03/

Details:

Looking for an experienced/skilled Joomla! back end developer for an ongoing longterm project which will include many sub-projects.

Your job will be:
• Developing new Joomla! Extensions from the scratch
• Extending our existing Joomla! Extensions with new features
• Fixing bugs in our existing Joomla! Extensions

You must bring the following skills:
• PHP
• MVC
• MySQL
• Javascript/jQuery
• HTML/Css
• Joomla 3+
• Virtuemart 3+

We do NOT looking for someone who:
• just created some Joomla! websites with existing extensions & themes
• unexperienced Joomla! developers

 

Client Budget: Hourly

Client Name:

Bid: $18.75/hr (Net: $15/hr)

Cover Letter:

Hello,

I am a PHP and Joomla expert. I also proficient on MySQL, Javascript/jQuery and HTML/CSS. I have strong knowledge on OOP and MVC concepts. I can develop/modify joomla websites and develop/modify the joomla modules, components and extensions. I have an experience to work on a Joomla website and Virtuemart component as the shopping cart platform. The website url is https://www.mitchellmccabe.com.au/. I worked on many things like modified the virtuemart component and settings (Customers information, checkout process, the email confirmation, SEO, etc), fixing the social media problems, fixing the website slider, etc.

I am happy to discuss further regarding your requirement.

Kind Regards,

Satria F

Are you familiar with: • developing Joomla! Extensions from the scratch? • fixing bugs in existing Joomla! Extensions? • SVN/Subversion??
I am familiar with Joomla components, modules and extensions. I also can fix joomla problems. I used to use subversion/svn a long time ago and I need a little time to refresh my memory but now I am familiar with another version controll, github.

MEAN.JS Stack Installation on Ubuntu 14.04

References: https://www.ostechnix.com/install-mean-js-stack-ubuntu/
local: http://myprojects.advchaweb.com/index.php/2016/08/24/my-ubuntu-14-04-and-apps-installation-error-and-solution/

MEAN.JS is an Open-Source, full-Stack JavaScript solution for building fast, and robust web applications.

MEAN.JS  stack consists of the following:
MongoDB – NoSQL database.
Express – NodeJS server-side application web framework.
AngularJS – Client-side web application framework.
Node.js – JavaScript run-time, popular for being a web server platform.

I already installed almost all components needed in http://myprojects.advchaweb.com/index.php/2016/08/24/my-ubuntu-14-04-and-apps-installation-error-and-solution/.
Node:

npm:

MongoDb:

Bower:

Grunt:

Gulp:

OK. Now download and install MEAN.JS Stack (I put them in /Documents/node/ directory):

Go into the new directory created ‘meanjs’

Install the nodejs dependencies (it’ll take time):

Once all dependencies are installed, run the following command to install all the front-end modules (angularjs) needed for the application.

THERE IS SOME CONFUSION WHEN I TRIED TO RUN ‘grunt’ BECAUSE I ALWAYS GOT THIS MESSAGES

I TRIED TO FIND THE SOLUTION ON THE INTERNET (STACKOVERFLOWS: http://stackoverflow.com/questions/13925916/fatal-error-unable-to-find-local-grunt?rq=1, http://stackoverflow.com/questions/15483735/fatal-error-unable-to-find-local-grunt-when-running-grunt-command?noredirect=1&lq=1, http://stackoverflow.com/questions/41989435/fatal-error-unable-to-find-local-grunt-despite-grunt-installed-locally) OR https://github.com/gruntjs/grunt-cli/issues/101, I ALSO DID THID

or did this ‘npm init’

BUT ‘grunt’ NEVER WORK!!!
SOLUTION: I SHOULD USE ‘gulp’ INSTEAD OF ‘grunt’ (OR I THINK NO NEED TO USE ‘grunt’ ANYMORE???)

OR JUST TYPE ‘node server’ IS SAME!

NOW IT WORKS (http://localhost:3000/)NOTE: I ALSO ALREADY INSTALLED MEAN-CLI

THAT I CAN CREATE A NODE JS PROJECT LOCALLY WITHOUT HAVE TO DOWNLOAD/CLONE FROM GITHUB??? mean-cli FROM LINNOVATE??? LET’S GIVE A TEST! I WANT TO CREATE ‘test-project’:

Go into ‘test-project’ directory:

Install the dependencies (take a long time):

Then run ‘gulp’ to run the server

OR run ‘node server’

HERE IS THE LOOKS (http://localhost:3000/)WHICH ONE I SHOULD CHOOSE????
WHY THE PROJECTS SIZE IS VERY BIG (MORE THAN 250MB EACH)???
HOW ABOUT MERN VS MEAN ??? (R=ReactJS INSTEAD OF A=AngularJS) Pros AND Cons???

Phalcon CMF: Yona E-commerce

Source: https://github.com/oleksandr-torosh/yona-ecommerce

Yona E-commerce
E-commerce CMF based on Phalcon PHP Framework

Installation:

  1. clone the github repository

    Note: The description on the github said to clone with ‘git clone git@githubcom:oleksandr-torosh/yona-ecommerce.git’ BUT IT GAVE ME ERROR (ALSO the git url IS WRONG! it is supposed to ‘@github.com…’ NOT ‘@githucom…’
  2. Go into ‘yona-ecommerce/’ directory then use composer to install the dependencies
  3. Use ‘bower install’

    I got an error “Error: Cannot find module ‘internal/fs'”. From this https://github.com/bower/bower/issues/2393, I tried to run bower locally ‘npm install bower’

    Then run ‘node_modules/bower/bin/bower install’

    But when I tried to run again ‘bower install’, the error still persist!
    Actually I continued to execute #4 and #5 below but I still curious about the bower!
    I checked my current node (7.2.1) and npm (3.10.10) version

    BUT I CAN’T CHECK BOWER VERSION. IT SHOWED THE SAME ERROR LIKE ABOVE!

    I read some clue like install node earlier version (downgrade) like version 4.1.1

    Now my node version is 4.1.1

    Update npm

    But ‘bower install’ still showed the same error!
    THE WORKING SOLUTION IS DOWNGRADE NODE TO VERSION 6.9.1! First clean npm cache and remove ‘node_modules’ directory!

    Install node v 6.9.1

    Install bower (locally???)

    Check bower version (bower -v) is working now

    Now ‘bower install’ run well (SAME WITH ‘node_modules/bower/bin/bower install’ ABOVE!)

    from ‘bower.json’. It’s a list of packages that required. ‘.bowerrc’ is a file to put the bower setting like where to put the downloaded packages. From the content of .bowerrc

    SO ‘bower install’ would download the packages and put its into /public/components/ directory of this website!
  4. Next, run ‘npm install -g less’

     
  5. Then run ‘npm install -g less-plugin-clean-css’

     
  6. Set the file permission (it may be not good but i have to set all files in ‘yona-ecommerce’ to 777)

     
  7. Run it on your browser (http://localhost/works/phalcon/yona-ecommerce/public/).
    OK. This yona-ecommerce still in early version (version 0.0.1???) so no much can be displayed. It only showed
    ‘Frontend
    index’
    The website setting in /config/.env file
    I can modify the frontend text in /app/views/frontend/index/index.volt file
    Also there is still no database (there is a migration file in /storage/migrations/ but I dont know how to do it. https://docs.phalconphp.com/en/latest/reference/migrations.html???)
    No much to learn from this BUT I THINK I CAN LEARN IT FROM YONA-CMS (The developer is same though)

Phalcon CMS: Yona CMS

Source: https://github.com/oleksandr-torosh/yona-cms
Installation:

  1. Use composer
  2. Go into ‘yona-cms’ dir then modify the files permission
  3. Create a new database ‘yona-cms’ via PHPMyAdmin
  4. Import the tables from ‘yona-cms.sql’ file (available in root yona-cms)
  5. Modify /app/config/environment/development.php file for the database name, password and change the ‘base_path’ that suit with my local environment

    It worth also to modify ‘phinx.yml’ file in the root of yona-cms
  6. Run it on your web browser (Mine: http://localhost/works/phalcon/yona-cms/public/)The good thing is it’d also display the profiler bar (for development mode) at the bottom of the websiteFor the admin page (user login: yona, password:yonacmsphalcon), http://localhost/works/phalcon/yona-cms/public/admin. Here is the looksI STILL DIDN’T UNDERSTAND WHERE IS THE FILE FOR SETTING $_SERVER[‘APPLICATION_ENV’]. THE DEFAULT VALUE IS ‘development’. I DEBUGGED IT IN /public/index.php FILE. I HAVE SEARCHED ALL IN THE PHP, YML AND DATABASE FILE BUT DIDN’T FIND IT. AT LAST I FOUND IT IN /public/.htaccess FILE!!! IT USE APACHE AND IT’S UNEXPECTED. HERE IS THE LINE

    CAN READ ALSO http://stackoverflow.com/questions/13784116/setting-environment-variables-with-the-built-in-php-web-server.

Phalcon Developer Tools on Linux

Reference: https://docs.phalconphp.com/en/latest/reference/linuxtools.html

Developer Tools
These tools are a collection of useful scripts to generate skeleton code. Core components of your application can be generated with a simple command, allowing you to easily develop applications using Phalcon.
Make sure the phalcon module already installed.

Installation of Phalcon Developer Tools for Linux:

  1. Clone the tools
  2. Go into the directory then execute ”. ./phalcon.sh”, (don’t forget the dot at beginning of the command):

    At the end I got an error “ERROR: Phalcon extension isn’t installed…”. This is may be because my php cli version (php version 7) is different with my default php (php version 5.6). From the previous article, I only install phalcon for php 5.6. So change the php version for cli (read again http://myprojects.advchaweb.com/index.php/2016/09/16/update-ppa-for-php/) like this:

    When I did the last error command, it’s working now

     
  3. Create a symbolink link to the phalcon.php script:

    I think ‘phalcon’ can be used from everywhere now. even I don’t need to execute this command anymore

    Here is the ‘phalcon’ command running at home directory:

     

Use Phalcon Developer Tools for Projects (ref: https://docs.phalconphp.com/en/latest/reference/tools.html):

  1. Create a project
    Note: To enable the web tools (for web GUI) , add the ‘–enable-webtools’ after the project name

    SO it just not ‘phalcon create-project store’
  2. Open it on your browser (http://localhost/works/phalcon/store/). But I got this error:

    From this forum: https://forum.phalconphp.com/discussion/15389/volt-directory-cant-be-written, I tried to modify the files permission to ‘664’

    Then refresh, got another error:

    Now try to modify to ‘777’.

    Then refresh again AND IT’S WORKING NOW (http://localhost/works/phalcon/store/)

    The web tools (make sure you create your project with the webtools enabled)
    Open it on your browser http://localhost/works/phalcon/store/public/webtools.php. If you get the display like thisIt means the css and js file can’t be loaded properly. From this link: https://forum.phalconphp.com/discussion/15111/webtools-can-not-load-css-if-using-different-baseuri, I need to modify /app/config/config.php and add ‘staticUri’ like this:

    Then refresh again your browser (http://localhost/works/phalcon/store/public/webtools.php), Here is the displayNOTE: I FOUND ONLY ‘controller’ COMMAND IS WORKING, BUT ‘model’ and ‘scaffold’ COMMANDS IS NOT WORKING! I ALSO TRIED THE COMMAND LIKE ‘phalcon model products’ AND IT DON’T WORK. I THINK THE PROBLEM IN THE DEV TOOLS! I put this issue in phalcon github (https://github.com/phalcon/phalcon-devtools/issues/976): Cannot create model via devtools but can create controller
    “I can create controller via the devtools (and webtools) but I can’t create model. Here is the command:

    $ phalcon model products

    The result:

    Phalcon DevTools (3.0.4)
    Error: Table “products” does not exist.

    I also can’t do it via webtools. I fill the form like the table name and click ‘Generate’. The weird thing happened. it said ‘Models were created successfully’ but I see nothing.

    I also found the url for the webtools is a bit weird (it’s working though). when I opened it the first time, the url is like this: http://localhost/works/phalcon/store/public/webtools.php
    but after i clicked the others links (do some stuff on controllers, models, system info, etc), the ‘/webtools.php/’ keep added and make the url longer, so it’d be like this: http://localhost/works/phalcon/store/public/webtools.php/webtools.php/webtools.php/webtools.php/webtools.php?_url=/controllers/list.

    Info:
    Phalcon DevTools Version: 3.0.4
    Phalcon Version: 3.0.3
    AdminLTE Version: 2.3.6
    OS: Linux teddy-K43SJ 4.4.0-62-generic #83 14.04.1-Ubuntu SMP Wed Jan 18 18:10:30 UTC 2017 x86_64
    PHP Version: 5.6.30-1+deb.sury.org~trusty+1
    PHP SAPI: apache2handler”
    I’M WAITING THE ANSWER!!!

    Test Phalcon (https://docs.phalconphp.com/en/latest/reference/tools.html)
    Generating Controllers

    The command “create-controller” generates controller skeleton structures. It’s important to invoke this command inside a directory that already has a Phalcon project.

    This is the content of /store/app/controllers/TestController.php

    Modify the above controller like this:

    Then open it on your browser: http://localhost/works/phalcon/store/test
    Result of the test controller:
    Create a new database ‘phalcon_store’ (via phpmyadmin)
    Preparing Database Settings
    When a project is generated using developer tools. A configuration file can be found in app/config/config.php (NOT config.ini file).

    To generate models or scaffold, you will need to change the settings used to connect to your database. I CAN’T USE DEVTOOL FOR CREATING MODEL LIKE I SAID ABOVE, SO I’LL DO IT MANUALLY! SO create a new file ‘Products.php’ in /app/models/ directory. I also added setter/getter methods

    SCAFFOLD ALSO SEEMS DONT WORK VIA DEVTOOLS!

    SO FOR SAVING TIME, I DOWNLOAD THE WORKING CODE FROM https://github.com/gsokolowski/ph-store. –> THE LOOKS STILL SAME WITH MINE. NO DIFFERENT. ONLY SHOW ‘Congratulation.
    HERE IS LOCAL PHALCON PROJECT WORKING: http://localhost/works/phalcon/invo. –>LEARN THIS!

    NOTES:
    I found when the first time the page is loaded (index.php in /public/ dir), it’d be referred to /app/views/index.volt. then content “{{ content }}” would be picked up from /app/views/index/index.volt. We can modify this file to change the frontend content

    Here is the looks (http://localhost/works/phalcon/store/)

     

Phalcon Compilation and Installation on Ubuntu 14.04

Reference: https://phalconphp.com/en/download
How To Install Phalcon PHP Framework on Ubuntu 14.10, 14.04 & 12.04
Phalcon is a C extension, so you need to download a binary for your platform or compile it from source code (SO INSTALL THE BINARY OR COMPILE! CHOOSE ONLY OF THEM!).
Installation on Ubuntu 14.04:

Install the binary (the easiest way but it don’t mean it’d be working!)

Install the package

SO the installation is failed! I got the above error. May be because Ubuntu 14.04 has not been supported yet (https://forum.phalconphp.com/discussion/6217/ubuntu-cant-install-phalcon). SO IT’S TIME TO COMPILE THE SOURCE!
But before installing the source, we need some required packages. Check those packages if they haven’t been installed in your machine. My ubuntu 14.04 already has ‘python-software-properties’, ‘software-properties-common’, ‘php5-dev’, ‘php5-mysql’, ‘gcc’ and ‘libpcre3-dev’. So now I just need to compile the phalcon source code:

  1. Clone the phalcon code
  2. Go into the ‘cphalcon/build’ directory

     
  3. then install

    OK. It takes a while to install it. It recommended to install apache web server.
  4. Then Create phalcon.ini file in /etc/php/5.6/mods-available/ directory (because I use php 5.6)

    Then type ‘extension=phalcon.so’ (WITHOUT QUOTE!)
    That mean we can use ‘phalcon’ in PHP 5.6 ONLY! TO enable the mod in the others php version, we can use the same method!
    No need to use command ‘sudo phpenmod phalcon’ anymore!
    NOTE: Somehow I can’t use this command instead of the above

    I also tried to write the extension directly in ‘/etc/php/5.6/apache2/php.ini’ but apache showed error when trying to restart it!
  5. Then restart the apache web server

    If there is no error, then check it on php_info()I CAN ALSO CHECK THE MODULES INSTALLED FROM COMMAND TERMINAL:

    SO COMPILATION AND INSTALLATION SUCCESS!
    TO TRY AND LEARN PHALCON DEEPER (CMS, BLOG, LOGIN, ETC), THIS IS A GOOD COMPILATION: https://github.com/sergeyklay/awesome-phalcon.

Tesseract Training

OK. This is really hard and also I dont have enough knowledge to do the training process. I have to learn much and comprehend all the process. I need to spend more time to do this. I have spent two days for this.

The testing files in /Documents/cpp/tesseract/testing/ directory. First I need to convert the pdf file (export1.pdf) to tiff image with density 500dpi and keep the quality 100%

I got the tif image export1.tif with more than 190MB size!!! I dont know if this is correct or not. I sliced the export1.tif image and I created 14 tif images as samples from the tif image to train tesseract to recognize the text on the images. Then I use LIOS (Application -> Graphics -> Tesseract-Trainer) to train the 14 images and make the boxes for them. I read another article that to get the good result, I need to have more than 10 samples. I got 14 so I think it’d be better. This training process is really tedious. I have to check each character and make sure they all correct. Sometimes (many times) it showed the wrong characters and wrong box selection. I NEED TO CREATE A TUTORIAL HOW TO TRAIN THE IMAGE WITH LIOS!!! AT the end it’s failed miserably when I tested with the train data. The train data is in /usr/local/share/tessdata/ directory. The last train data is ‘train4’. I create two test with the training data. First, I use the train4 data

The result is SHAME! then I want to use the default ‘eng’ train data to see the comparison

The result is better BUT STILL A CRAP!
I see in /usr/local/share/tessdata/ directory there are many files related to the ‘eng’:

BUT I ONLY HAVE ONE FILE

I THINK I DIDN’T PREPARE THE TRAINING CORRECTLY OR MAY BE I MISS SOMETHING????
READ SOME TUTORIAL:
https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00
https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality
https://github.com/tesseract-ocr/tesseract/wiki/NeuralNetsInTesseract4.00
http://pretius.com/how-to-prepare-training-files-for-tesseract-ocr-and-improve-characters-recognition/