From f8a25e034daed18f931c60f700d9572c8552ea6a Mon Sep 17 00:00:00 2001 From: HexToString <506181616@qq.com> Date: Wed, 29 Dec 2021 04:23:01 +0000 Subject: [PATCH] fix doc and ocr --- examples/C++/PaddleOCR/ocr/ocr_cpp_client.py | 13 +++++++++++-- examples/C++/xpu/bert/README.md | 2 +- python/paddle_serving_app/reader/batching.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/C++/PaddleOCR/ocr/ocr_cpp_client.py b/examples/C++/PaddleOCR/ocr/ocr_cpp_client.py index 534e24cd..c66d597b 100644 --- a/examples/C++/PaddleOCR/ocr/ocr_cpp_client.py +++ b/examples/C++/PaddleOCR/ocr/ocr_cpp_client.py @@ -21,6 +21,7 @@ import os import cv2 from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose +from paddle_serving_app.reader import OCRReader client = Client() # TODO:load_client need to load more than one client model. @@ -44,5 +45,13 @@ for img_file in os.listdir(test_img_dir): feed={"image": image}, fetch=["ctc_greedy_decoder_0.tmp_0", "softmax_0.tmp_0"], batch=True) - #print("{} {}".format(fetch_map["price"][0], data[0][1][0])) - print(fetch_map) + result = {} + result["score"] = fetch_map["softmax_0.tmp_0"] + del fetch_map["softmax_0.tmp_0"] + rec_res = OCRReader().postprocess(fetch_map, with_score=False) + res_lst = [] + for res in rec_res: + res_lst.append(res[0]) + result["res"] = res_lst + + print(result) diff --git a/examples/C++/xpu/bert/README.md b/examples/C++/xpu/bert/README.md index 676ac361..1cafe07a 100644 --- a/examples/C++/xpu/bert/README.md +++ b/examples/C++/xpu/bert/README.md @@ -7,7 +7,7 @@ tar zxvf bert_base_chinese.tar.gz ``` ### convert model ``` -python3 -m paddle_serving_client.convert --dirname bert_base_chinese --model_filename bert_base_chinese/model.pdmodel --params_filename bert_base_chinese/model.pdiparams +python3 -m paddle_serving_client.convert --dirname bert_base_chinese --model_filename model.pdmodel --params_filename model.pdiparams ``` ### or, you can get the serving saved model directly ``` diff --git a/python/paddle_serving_app/reader/batching.py b/python/paddle_serving_app/reader/batching.py index 5ec5f320..4cc85b29 100644 --- a/python/paddle_serving_app/reader/batching.py +++ b/python/paddle_serving_app/reader/batching.py @@ -108,7 +108,7 @@ def pad_batch_data(insts, input_mask_data = np.array( [[1] * len(inst) + [0] * (max_len - len(inst)) for inst in insts]) input_mask_data = np.expand_dims(input_mask_data, axis=-1) - return_list += [input_mask_data.astype("float32")] + return_list += [input_mask_data] if return_max_len: return_list += [max_len] -- GitLab