yangjun 5709eb762c 提交PaddleOCR dygraph分支 6cbd7d1ecef832d428e21ef98c44382c5384d8f7 1 سال پیش
..
imgs_words_en b0c1878a97 初始化PaddleOCR 1 سال پیش
include b0c1878a97 初始化PaddleOCR 1 سال پیش
src b0c1878a97 初始化PaddleOCR 1 سال پیش
.gitignore b0c1878a97 初始化PaddleOCR 1 سال پیش
Makefile b0c1878a97 初始化PaddleOCR 1 سال پیش
README.md b0c1878a97 初始化PaddleOCR 1 سال پیش
README_ch.md b0c1878a97 初始化PaddleOCR 1 سال پیش
arm-none-eabi-gcc.cmake b0c1878a97 初始化PaddleOCR 1 سال پیش
configure_avh.sh b0c1878a97 初始化PaddleOCR 1 سال پیش
convert_image.py 5709eb762c 提交PaddleOCR dygraph分支 6cbd7d1ecef832d428e21ef98c44382c5384d8f7 1 سال پیش
corstone300.ld b0c1878a97 初始化PaddleOCR 1 سال پیش
requirements.txt b0c1878a97 初始化PaddleOCR 1 سال پیش
run_demo.sh b0c1878a97 初始化PaddleOCR 1 سال پیش

README.md

English | 简体中文

Running PaddleOCR text recognition model on bare metal Arm(R) Cortex(R)-M55 CPU using Arm Virtual Hardware

This folder contains an example of how to run a PaddleOCR model on bare metal Cortex(R)-M55 CPU using Arm Virtual Hardware.

Running environment and prerequisites

Case 1: If the demo is run in Arm Virtual Hardware Amazon Machine Image(AMI) instance hosted by AWS/AWS China, the following software will be installed through configure_avh.sh script. It will install automatically when you run the application through run_demo.sh script. You can refer to this guide to launch an Arm Virtual Hardware AMI instance.

Case 2: If the demo is run in the ci_cpu Docker container provided with TVM, then the following software will already be installed.

Case 3: If the demo is not run in the ci_cpu Docker container, then you will need the following:

In case2 and case3:

You will need to update your PATH environment variable to include the path to cmake 3.19.5 and the FVP. For example if you've installed these in /opt/arm , then you would do the following:

export PATH=/opt/arm/FVP_Corstone_SSE-300/models/Linux64_GCC-6.4:/opt/arm/cmake/bin:$PATH

You will also need TVM which can either be:

  • Installed from TLCPack(see TLCPack)
  • Built from source (see Install from Source)
    • When building from source, the following need to be set in config.cmake:
      • set(USE_CMSISNN ON)
      • set(USE_MICRO ON)
      • set(USE_LLVM ON)

Running the demo application

Type the following command to run the bare metal text recognition application (src/demo_bare_metal.c):

./run_demo.sh

If you are not able to use Arm Virtual Hardware Amazon Machine Image(AMI) instance hosted by AWS/AWS China, specify argument --enable_FVP to 1 to make the application run on local Fixed Virtual Platforms (FVPs) executables.

./run_demo.sh --enable_FVP 1

If the Ethos(TM)-U platform and/or CMSIS have not been installed in /opt/arm/ethosu then the locations for these can be specified as arguments to run_demo.sh, for example:

./run_demo.sh --cmsis_path /home/tvm-user/cmsis \
--ethosu_platform_path /home/tvm-user/ethosu/core_platform

With run_demo.sh to run the demo application, it will:

  • Set up running environment by installing the required prerequisites automatically if running in Arm Virtual Hardware Amazon AMI instance(not specify --enable_FVP to 1)
  • Download a PaddleOCR text recognition model
  • Use tvmc to compile the text recognition model for Cortex(R)-M55 CPU and CMSIS-NN
  • Create a C header file inputs.c containing the image data as a C array
  • Create a C header file outputs.c containing a C array where the output of inference will be stored
  • Build the demo application
  • Run the demo application on a Arm Virtual Hardware based on Arm(R) Corstone(TM)-300 software
  • The application will report the text on the image and the corresponding score.

Using your own image

The create_image.py script takes a single argument on the command line which is the path of the image to be converted into an array of bytes for consumption by the model.

The demo can be modified to use an image of your choice by changing the following line in run_demo.sh

python3 ./convert_image.py path/to/image

Model description

The example is built on PP-OCRv3 English recognition model released by PaddleOCR. Since Arm(R) Cortex(R)-M55 CPU does not support rnn operator, we delete the unsupported operator based on the PP-OCRv3 text recognition model to obtain the current 2.7M English recognition model.

PP-OCRv3 is the third version of the PP-OCR series model. This series of models has the following features:

  • PP-OCRv3: ultra-lightweight OCR system: detection (3.6M) + direction classifier (1.4M) + recognition (12M) = 17.0M
  • Support more than 80 kinds of multi-language recognition models, including English, Chinese, French, German, Arabic, Korean, Japanese and so on. For details
  • Support vertical text recognition, and long text recognition