readme.md 3.4 KB
Newer Older
M
MissPenguin 已提交
1
English | [简体中文](readme_ch.md)
L
add  
LDOUBLEV 已提交
2

M
MissPenguin 已提交
3
# Jetson Deployment for PaddleOCR
L
add  
LDOUBLEV 已提交
4

M
MissPenguin 已提交
5
This section introduces the deployment of PaddleOCR on Jetson NX, TX2, nano, AGX and other series of hardware.
L
add  
LDOUBLEV 已提交
6 7


M
MissPenguin 已提交
8
## 1. Prepare Environment
L
add  
LDOUBLEV 已提交
9

M
MissPenguin 已提交
10
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;
L
add  
LDOUBLEV 已提交
11

M
MissPenguin 已提交
12
1. Install PaddlePaddle in Jetson
L
add  
LDOUBLEV 已提交
13

M
MissPenguin 已提交
14 15
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.
L
add  
LDOUBLEV 已提交
16

M
MissPenguin 已提交
17
Install PaddlePaddle:
L
add  
LDOUBLEV 已提交
18 19 20 21 22
```shell
pip3 install -U paddlepaddle_gpu-2.3.0rc0-cp36-cp36m-linux_aarch64.whl
```


M
MissPenguin 已提交
23
2. Download PaddleOCR code and install dependencies
L
add  
LDOUBLEV 已提交
24

M
MissPenguin 已提交
25
Clone the PaddleOCR code:
L
add  
LDOUBLEV 已提交
26 27 28 29
```
git clone https://github.com/PaddlePaddle/PaddleOCR
```

M
MissPenguin 已提交
30
and install dependencies:
L
add  
LDOUBLEV 已提交
31 32 33 34 35
```
cd PaddleOCR
pip3 install -r requirements.txt
```

M
MissPenguin 已提交
36
*Note: Jetson hardware CPU is poor, dependency installation is slow, please wait patiently*
L
add  
LDOUBLEV 已提交
37

M
MissPenguin 已提交
38
## 2. Perform prediction
L
add  
LDOUBLEV 已提交
39

M
MissPenguin 已提交
40
Obtain the PPOCR model from the [document](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_en/ppocr_introduction_en.md#6-model-zoo) model library. The following takes the PP-OCRv3 model as an example to introduce the use of the PPOCR model on Jetson:
L
add  
LDOUBLEV 已提交
41

M
MissPenguin 已提交
42
Download and unzip the PP-OCRv3 models.
L
add  
LDOUBLEV 已提交
43 44 45 46 47 48 49
```
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
```

M
MissPenguin 已提交
50
The text detection inference:
L
add  
LDOUBLEV 已提交
51 52 53 54 55
```
cd PaddleOCR
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
```

M
MissPenguin 已提交
56
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.
L
add  
LDOUBLEV 已提交
57 58 59
![](./images/det_res_french_0.jpg)


M
MissPenguin 已提交
60
The text recognition inference:
L
add  
LDOUBLEV 已提交
61 62 63 64
```
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"
```

M
MissPenguin 已提交
65
After executing the command, the predicted information will be printed on the terminal, and the output is as follows:
L
add  
LDOUBLEV 已提交
66 67 68 69
```
[2022/04/28 15:41:45] root INFO: Predicts of ./doc/imgs_words/en/word_2.png:('yourself', 0.98084533)
```

M
MissPenguin 已提交
70
The text  detection and text recognition inference:
L
add  
LDOUBLEV 已提交
71 72

```
M
MissPenguin 已提交
73
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"
L
add  
LDOUBLEV 已提交
74 75
```

M
MissPenguin 已提交
76
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.
L
add  
LDOUBLEV 已提交
77 78
![](./images/00057937.jpg)

M
MissPenguin 已提交
79
To enable TRT prediction, you only need to set `--use_tensorrt=True` on the basis of the above command:
L
add  
LDOUBLEV 已提交
80
```
M
MissPenguin 已提交
81
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
L
add  
LDOUBLEV 已提交
82 83
```

M
MissPenguin 已提交
84
For more ppocr model predictions, please refer to[document](../../doc/doc_en/models_list_en.md)