Get Started with a Japanese Text Recognition demo in the Intel® Distribution of OpenVINO™ toolkit

ID 659775
Updated 8/5/2020
Version Latest
Public

author-image

By

This article describes how to run the Handwritten Japanese Text Recognition demo found in the Intel® Distribution of OpenVINO™ toolkit.

Requirements

Skills

Familiarity with GNU Linux* commands

Hardware

UP* Xtreme*: i7-8665UE 1.70GHz 4 Core

System, software and more

Distro Ubuntu 18.04.3 LTS Bionic Beaver
Kernel

Linux* kernel 5.0.0-1

Toolkit Intel® Distribution of OpenVINO™ toolkit
Model handwritten-japanese-recognition-0001
Depends numpy opencv-python

What is the Kondate Nakayosi Character List?

The Kondate Nakayosi character list includes 4441 characters. This list can be used to check against any characters you may want to use in your testing or demo. This list is included with the demo as a txt file.

Run the Original Demo

The demo uses handwritten input and when inference is run, the results of the input are displayed. For the purposes of this demo, the Up Xtreme
This section includes details for the following steps:

  1. Download the model
  2. Initialize the environment
  3. Change directory
  4. Run demo
  5. Validate with the displayed results

Step 1: Download the model

There are several ways to download the model. A model downloader script, downloader.py is included with the toolkit in the deployment_tools/tools directory in the model_downloader directory. For more information about downloading models using the model downloader, visit Model Downloader and other automation tools.

In /opt/intel/openvino/deployment_tools/tools/model_downloader, use the following command to download the handwritten japanese text models:

downloader.py --name handwritten*

A sample of the path to the downloaded model is found below.

model for text recognition directory

Demo script

The original demo is found in the python_demos directory.

/opt/intel/openvino/deployment_tools/inference_engine/demos/python_demos/handwritten_japanese_recognition_demo

The directory tree below lists the contents of the directory.

├── data
│ ├── kondate_nakayosi_char_list.txt
│ └── test.png
├── handwritten_japanese_recognition_demo.py
├── models.lst
├── README.md
├── requirements.txt
└── utils
├── codec.py
├── __init__.py
└── __pycache__
├── codec.cpython-36.pyc
└── __init__.cpython-36.pyc

3 directories, 10 files

The original handwritten image file is named: test.png

original characters for demo

Step 2: Initialize environment

Manually initialize the environment quickly by running the following command. Alternately, type "source" rather than use the replacement "." for source when initializing the environment.

. /opt/intel/openvino/bin/setupvars.sh

Use the same terminal to run the demo.

Step 3: Change directory

To run the python script, move to the handwritten_japanese_recognition_demo directory.

cd /opt/intel/openvino/inference_engine/demos/python_demos/handwritten_japanese_recognition_demo

Step 4: Run demo

Run the python script, handwritten_japanese_recognition_demo.py at the command line. Add the input (-i) image and model (-m) with path to the model in the command.

python3 handwritten_japanese_recognition_demo.py -i data/test.png -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/handwritten-japanese-recognition-0001/FP16/handwritten-japanese-recognition-0001.xml

Troubleshooting Tip: If the notification "import cv2 ModuleNotFoundError:init No module named 'cv2' diplays, initialize the environment in the current terminal.

Step 5: Validate with the displayed results

results of original demo

Next Up: Modify the demo

Modify the Demo

In this example, the text used was not handwritten but a typed character is used.

Step 1: Select Text

Selected character to test text recognition is found below.

薫 kanji for kaoru

Step 2: Replace test.png file with an image of the selected character(s)

Replace the current test.png with this image or change the name and use this in the command in place of test.png

symbol for kaoruWhen inference is run, this character will display as the result.

results of inference

The character was included in the kondate akayoshi character list (kondate_nakayosi_char_list.txt).

Next Steps: Handwritten

For the next steps, try other characters. Replace the input image and run the python script.

Remember, the characters are included in the kondate_nakayosi_char_list.txt file.

Command Roll

# In /opt/intel/openvino/deployment_tools/tools/model_downloader, use the following command to download the handwritten japanese text models

# download the model

downloader.py --name handwritten*

# location of the demo

/opt/intel/openvino/deployment_tools/inference_engine/demos/python_demos/handwritten_japanese_recognition_demo

# initialize environment if not already

. /opt/intel/openvino/bin/setupvars.sh

# The original demo is found in the python_demos directory.

cd /opt/intel/openvino/inference_engine/demos/python_demos/handwritten_japanese_recognition_demo

# run the demo
# -i input, -m model

python3 handwritten_japanese_recognition_demo.py -i data/test.png -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/handwritten-japanese-recognition-0001/FP16/handwritten-japanese-recognition-0001.xml

 

About the author:
marcia kaoru wilburは、GNU Linux +フリーソフトウェアのDebian開発者およびベテランです。彼女の母親、マサヨウィルバーは日本人で、ソルトレイクシティの系図センターの引退した翻訳者です。