readme_en.md 3.38 KB
Newer Older
LDOUBLEV's avatar
LDOUBLEV committed
1

LDOUBLEV's avatar
LDOUBLEV committed
2
# Jetson Deployment for PaddleOCR
LDOUBLEV's avatar
LDOUBLEV committed
3

LDOUBLEV's avatar
LDOUBLEV committed
4
This section introduces the deployment of PaddleOCR on Jetson NX, TX2, nano, AGX and other series of hardware.
LDOUBLEV's avatar
LDOUBLEV committed
5
6


LDOUBLEV's avatar
LDOUBLEV committed
7
## 1. Prepare Environment
LDOUBLEV's avatar
LDOUBLEV committed
8

LDOUBLEV's avatar
LDOUBLEV committed
9
You need to prepare a Jetson development hardware. If you need TensorRT, you need to prepare the TensorRT environment. It is recommended to use TensorRT version 7.1.3;
LDOUBLEV's avatar
LDOUBLEV committed
10

LDOUBLEV's avatar
LDOUBLEV committed
11
1. Install PaddlePaddle in Jetson
LDOUBLEV's avatar
LDOUBLEV committed
12

LDOUBLEV's avatar
LDOUBLEV committed
13
14
The PaddlePaddle download [link](https://www.paddlepaddle.org.cn/inference/user_guides/download_lib.html#python)
Please select the appropriate installation package for your Jetpack version, cuda version, and trt version. Here, we download paddlepaddle_gpu-2.3.0rc0-cp36-cp36m-linux_aarch64.whl.
LDOUBLEV's avatar
LDOUBLEV committed
15

LDOUBLEV's avatar
LDOUBLEV committed
16
Install PaddlePaddle:
LDOUBLEV's avatar
LDOUBLEV committed
17
```shell
LDOUBLEV's avatar
LDOUBLEV committed
18
pip3 install -U paddlepaddle_gpu-2.3.0rc0-cp36-cp36m-linux_aarch64.whl
LDOUBLEV's avatar
LDOUBLEV committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
```


2. Download PaddleOCR code and install dependencies

Clone the PaddleOCR code:
```
git clone https://github.com/PaddlePaddle/PaddleOCR
```

and install dependencies:
```
cd PaddleOCR
pip3 install -r requirements.txt
```

LDOUBLEV's avatar
LDOUBLEV committed
35
*Note: Jetson hardware CPU is poor, dependency installation is slow, please wait patiently*
LDOUBLEV's avatar
LDOUBLEV committed
36
37
38

## 2. Perform prediction

LDOUBLEV's avatar
LDOUBLEV committed
39
Obtain the PPOCR model from the [document](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/ppocr_introduction.md#6-%E6%A8%A1%E5%9E%8B%E5%BA%93) model library. The following takes the PP-OCRv3 model as an example to introduce the use of the PPOCR model on Jetson:
LDOUBLEV's avatar
LDOUBLEV committed
40
41
42
43
44
45
46
47
48
49
50
51

Download and unzip the PP-OCRv3 models.
```
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar
tar xf ch_PP-OCRv3_det_infer.tar
tar xf ch_PP-OCRv3_rec_infer.tar
```

The text detection inference:
```
cd PaddleOCR
LDOUBLEV's avatar
LDOUBLEV committed
52
python3 tools/infer/predict_det.py --det_model_dir=./inference/ch_PP-OCRv2_det_infer/  --image_dir=./doc/imgs/french_0.jpg  --use_gpu=True
LDOUBLEV's avatar
LDOUBLEV committed
53
54
```

LDOUBLEV's avatar
LDOUBLEV committed
55
56
57
58
After executing the command, the predicted information will be printed out in the terminal, and the visualization results will be saved in the `./inference_results/` directory.
![](./images/det_res_french_0.jpg)


LDOUBLEV's avatar
LDOUBLEV committed
59
60
The text recognition inference:
```
LDOUBLEV's avatar
LDOUBLEV committed
61
62
63
64
65
66
python3 tools/infer/predict_det.py --rec_model_dir=./inference/ch_PP-OCRv2_rec_infer/  --image_dir=./doc/imgs_words/en/word_2.png  --use_gpu=True --rec_image_shape="3,48,320"
```

After executing the command, the predicted information will be printed on the terminal, and the output is as follows:
```
[2022/04/28 15:41:45] root INFO: Predicts of ./doc/imgs_words/en/word_2.png:('yourself', 0.98084533)
LDOUBLEV's avatar
LDOUBLEV committed
67
68
69
70
71
```

The text  detection and text recognition inference:

```
LDOUBLEV's avatar
LDOUBLEV committed
72
python3 tools/infer/predict_system.py --det_model_dir=./inference/ch_PP-OCRv2_det_infer/ --rec_model_dir=./inference/ch_PP-OCRv2_rec_infer/ --image_dir=./doc/imgs/00057937.jpg --use_gpu=True --rec_image_shape="3,48,320"
LDOUBLEV's avatar
LDOUBLEV committed
73
74
```

LDOUBLEV's avatar
LDOUBLEV committed
75
76
77
After executing the command, the predicted information will be printed out in the terminal, and the visualization results will be saved in the `./inference_results/` directory.
![](./images/00057937.jpg)

LDOUBLEV's avatar
LDOUBLEV committed
78
79
To enable TRT prediction, you only need to set `--use_tensorrt=True` on the basis of the above command:
```
LDOUBLEV's avatar
LDOUBLEV committed
80
python3 tools/infer/predict_system.py --det_model_dir=./inference/ch_PP-OCRv2_det_infer/ --rec_model_dir=./inference/ch_PP-OCRv2_rec_infer/ --image_dir=./doc/imgs/  --rec_image_shape="3,48,320" --use_gpu=True --use_tensorrt=True
LDOUBLEV's avatar
LDOUBLEV committed
81
82
```

LDOUBLEV's avatar
LDOUBLEV committed
83
For more ppocr model predictions, please refer to[document](../../doc/doc_en/models_list_en.md)