Industrial Text Line Recognition
In this tutorial, you’ll run the Industrial Text Line Recognition reference implementation to verify that Edge Insights for Industrial was installed successfully and to start getting familiar with its modules and structure. By following this tutorial, you will learn:
How to add a new custom/user application to Edge Insights for Industrial
How to rebuild Edge Insights for Industrial with this new application
How to visualize the results of the custom application
This reference implementation provides an AI-enabled approach to recognize characters from print text line using the deep learning method.
Industrial Text Line Recognition is a reference implementation that can be executed as part of the Edge Insights for Industrial package. If you have not installed that package yet, you can download it here and then follow the Edge Insights for Industrialinstallation instructions.
Target System Requirements
Ubuntu* 18.04 LTS
Intel® Core™ i5 processor or above with 16GB of RAM
How it Works
The application uses the inference engine included in the Intel® Distribution of OpenVINO™ toolkit. The reference implementation shows an example of how Industrial Text Line Recognition algorithm can be leveraged in industrial scenarios.
Print text line video: Sample video that is used to simulate a live camera stream. The video includes 300 print text images.
Inference Module: Ingest the frames from the camera stream and performs inference on each frame to recognize characters. The predicted result of each frame is also recorded and displayed on the output Visualizer window of the Edge Insights for Industrial software stack.
All communication between modules occurs over the Edge Insights for Industrial Message Bus. This reference implementation is a sample application that can be executed using the established pipeline.
Get Started
The Industrial Text Line Recognition reference implementation is a plug-and-play application developed for the Edge Insights for Industrial package.
Industrial Text Line Recognition is a reference implementation that can be executed as part of the Edge Insights for Industrial package. If you have not installed that package yet, you can download it here and then follow the Edge Insights for Industrialinstallation instructions.
Step 1: Add Industrial Text Line Recognition UDF Components
Copy the Industrial Text Line Recognition UDF file to the Edge Insights for Industrial UDFs directory:
# Set Edge Insights for Industrial home path as environment variable EII_HOME=<path_to_install_dir/IEdgeInsights/> # Copy Text Line Recognition UDF file to the UDFs directory cp -r PyTextLineRecognition/ $EII_HOME/CustomUdfs/.
Modify the Visualizer and WebVisualizer configuration files to add Industrial Text Line Recognition to the IEdgeInsights pipeline:
NOTE:We recommend that you make copies of the original $EII_HOME/Visualizer/config.json and $EII_HOME/WebVisualizer/config.json files before proceeding. These files needed to be rewritten to modify the pipeline to use the Industrial Text Line Recognition application files instead of the default PCB demo application.Make copies of the original Visualizer and WebVisualizer config.json files:
mv $EII_HOME/Visualizer/config.json $EII_HOME/Visualizer/config.json_original mv $EII_HOME/WebVisualizer/config.json $EII_HOME/WebVisualizer/config.json_original
Copy the new Visualizer and WebVisualizer config.json files to execute the Industrial Text Line Recognition application.
Optionally, edit the PyTextLineRecognition/config.json to use the inference hardware of choice [CPU/GPU/Myriad/HDDL]. Default is CPU.
NOTE:The deep learning model used in the reference implementation is a deep model, and hence would take a few minutes for the initial loading into an accelerator (Myriad/HDDL) memory.cp vis_config.json $EII_HOME/Visualizer/config.json cp webvis_config.json $EII_HOME/WebVisualizer/config.json
Copy the custom UDF yml file to include the custom text line recognition UDF container:
cp video-streaming-textlineUDF.yml $EII_HOME/build/usecases/.
Follow the Edge Insights for Industrial instructions to provision and launch the containers:
# Configure the IEdgeInsights pipeline to use custom UDF, Visualizer & Web Visualizer containers cd $EII_HOME/build/ sudo python3 builder.py -f usecases/video-streaming-textlineUDF.yml # Provision cd $EII_HOME/build/provision/ sudo -E ./provision.sh ../docker-compose.yml # Build and run cd $EII_HOME/build/ docker-compose -f docker-compose-build.yml build python_text_line_recognition docker-compose up -d # Enable visualizer display xhost +
The output will look similiar to:
Step 2: Check the Reference Implementation
The Edge Insights for Industrial builds the custom UDF, Visualizer and WebVisualizer containers. The custom UDF streams the sample video and performs Industrial Text Line Recognition on each frame to recognize the characters. Once the frame has been processed, the image is displayed on the Visualizer output window with the predicted result and inference time.
Execute the following command to ensure all the containers are running without errors:
sudo docker ps
Check for Success
If it was successful, the results will be similar to:
WebVisualizer Output
The sample video contains 300 printed text line images similar to the ones shown below:
(Optional) Stop the Vision Pipline
To stop the Edge Insights for Industrial software, execute the following command:
cd $EII_HOME/build/ docker-compose down
To revert to the default PCB Demo application, move the Visualizer and WebVisualizer config.json files to the original copies [Step 1.2.a] and rebuild using the instructions in Step 1.3.
(Optional) Standalone Testing
Testing the Industrial Text Line Recognition reference implementation outside of the Edge Insights for Industrial deployment environment requires OpenVINO™ to be installed on the development system. Please follow instructions on the OpenVINO™ website for installation steps for different inference hardware (CPU/Myriad/HDDL).
To execute the application on the host development system, follow the instructions below:
# Install dependencies pip install opencv-python==4.4.0.42 # Set OpenVINO env variables source /opt/intel/openvino/bin/setupvars.sh -pyver 3.6 # Run inference on single test image python3 text_line_recognizer.py\ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --image <path/to/input/test/image> Ex.: python3 text_line/text_line_recognizer.py \ --model text_line/ref/model.xml \ --label text_line/ref/labels.txt \ --image ./sample_data/2020081707:39:59E_217.jpg Expected output: Image : ./sample_data/2020081707:39:59E_217.jpg INFO:Textline_RECOGNITION:Prediction : 2020081707:39:59E INFO:Textline_RECOGNITION:Inference time : 0.08637118339538574 sec *********************************************************** # Run inference on directory of test images python3 text_line_recognizer.py \ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --dir <path/to/dir/of/test/images> Ex.: python3 text_line/text_line_recognizer.py \ --model text_line/ref/model.xml \ --label text_line/ref/labels.txt \ --dir ./sample_data/ Expected output: Image : ./sample_data/2019011413:26:44E_21.jpg INFO:Textline_RECOGNITION:Prediction : 2019011413:26:44E INFO:Textline_RECOGNITION:Inference time : 0.07046294212341309 sec *********************************************************** Image : ./sample_data/2020091921:05:31M_148.jpg INFO:Textline_RECOGNITION:Prediction : 2020091921:05:31M INFO:Textline_RECOGNITION:Inference time : 0.0416107177734375 sec ***********************************************************
Summary and Next Steps
In this tutorial, you successfully ran the Industrial Text Line Recognition application and displayed the result using the Edge Insights for Industrial Visualizer output.
To get access to the deep learning training algorithm that was used to generate the Industrial Text Line Recognition model, please contact your Intel account manager.
As a next step, see the Industrial Surface Defect Detection tutorial.