readme.md 2.42 KB
Newer Older
Tangmq's avatar
Tangmq committed
1
English | [简体中文](README_cn.md)
2

Tangmq's avatar
Tangmq committed
3
4
## Introduction
Many user hopes package the PaddleOCR service into an docker image, so that it can be quickly released and used in the docker or k8s environment.
5

Tangmq's avatar
Tangmq committed
6
This page provide some standardized code to achieve this goal. You can quickly publish the PaddleOCR project into a callable Restful API service through the following steps. (At present, the deployment based on the HubServing mode is implemented first, and author plans to increase the deployment of the PaddleServing mode in the futrue)
7

Tangmq's avatar
Tangmq committed
8
9
10
11
12
13
## 1. Prerequisites

You need to install the following basic components first:
a. Docker
b. Graphics driver and CUDA 10.0+(GPU)
c. NVIDIA Container Toolkit(GPU,Docker 19.03+ can skip this)
14
15
d. cuDNN 7.6+(GPU)

Tangmq's avatar
Tangmq committed
16
17
## 2. Build Image
a. Download PaddleOCR sourcecode
18
19
20
```
git clone https://github.com/PaddlePaddle/PaddleOCR.git
```
Tangmq's avatar
Tangmq committed
21
b. Goto Dockerfile directory(ps:Need to distinguish between cpu and gpu version, the following takes cpu as an example, gpu version needs to replace the keyword)
22
23
24
```
cd docker/cpu
```
Tangmq's avatar
Tangmq committed
25
c. Build image
26
27
28
29
```
docker build -t paddleocr:cpu . 
```

Tangmq's avatar
Tangmq committed
30
31
## 3. Start container
a. CPU version
32
33
34
```
sudo docker run -dp 8866:8866 --name paddle_ocr paddleocr:cpu
```
Tangmq's avatar
Tangmq committed
35
b. GPU version (base on NVIDIA Container Toolkit)
36
37
38
```
sudo nvidia-docker run -dp 8866:8866 --name paddle_ocr paddleocr:gpu
```
Tangmq's avatar
Tangmq committed
39
c. GPU version (Docker 19.03++)
40
41
42
```
sudo docker run -dp 8866:8866 --gpus all --name paddle_ocr paddleocr:gpu
```
Tangmq's avatar
Tangmq committed
43
d. Check service status(If you can see the following statement then it means completed:Successfully installed ocr_system && Running on http://0.0.0.0:8866/)
44
45
46
47
```
docker logs -f paddle_ocr
```

Tangmq's avatar
Tangmq committed
48
49
50
51
## 4. Test
a. Calculate the Base64 encoding of the picture to be recognized (if you just test, you can use a free online tool, like:https://freeonlinetools24.com/base64-image/)
b. Post a service request(sample request in sample_request.txt)

52
```
Tangmq's avatar
Tangmq committed
53
curl -H "Content-Type:application/json" -X POST --data "{\"images\": [\"Input image Base64 encode(need to delete the code 'data:image/jpg;base64,')\"]}" http://localhost:8866/predict/ocr_system
54
```
Tangmq's avatar
Tangmq committed
55
c. Get resposne(If the call is successful, the following result will be returned)
56
57
58
```
{"msg":"","results":[[{"confidence":0.8403433561325073,"text":"约定","text_region":[[345,377],[641,390],[634,540],[339,528]]},{"confidence":0.8131805658340454,"text":"最终相遇","text_region":[[356,532],[624,530],[624,596],[356,598]]}]],"status":"0"}
```