diff --git a/deploy/pdserving/ocr_local_server.py b/deploy/pdserving/ocr_local_server.py index 8761d1832319f39e89abd562b3fa67f345f4dd76..da3b895fccb65348ba52a588bae5a703f03085a4 100644 --- a/deploy/pdserving/ocr_local_server.py +++ b/deploy/pdserving/ocr_local_server.py @@ -60,6 +60,7 @@ class TextSystemHelper(TextSystem): return None, None img_crop_list = [] dt_boxes = sorted_boxes(dt_boxes) + self.dt_boxes = dt_boxes for bno in range(len(dt_boxes)): tmp_box = copy.deepcopy(dt_boxes[bno]) img_crop = self.get_rotate_crop_image(img, tmp_box) @@ -102,7 +103,8 @@ class OCRService(WebService): rec_res = self.text_system.postprocess(outputs, self.tmp_args) res = { "pred_text": [x[0] for x in rec_res], - "score": [str(x[1]) for x in rec_res] + "score": [str(x[1]) for x in rec_res], + "pos": [x.tolist() for x in self.text_system.dt_boxes] } return res diff --git a/deploy/pdserving/ocr_rpc_server.py b/deploy/pdserving/ocr_rpc_server.py index 199ea1f0a554e9eb6b7a451aa82e93a13b4d5698..cba210060adab9f2b5c6b461521d52a6f523fded 100644 --- a/deploy/pdserving/ocr_rpc_server.py +++ b/deploy/pdserving/ocr_rpc_server.py @@ -56,11 +56,11 @@ class TextSystemHelper(TextSystem): fetch_map = self.det_client.predict(feed, fetch) outputs = [fetch_map[x] for x in fetch] dt_boxes = self.text_detector.postprocess(outputs, self.tmp_args) - print(dt_boxes) if dt_boxes is None: return None, None img_crop_list = [] dt_boxes = sorted_boxes(dt_boxes) + self.dt_boxes = dt_boxes for bno in range(len(dt_boxes)): tmp_box = copy.deepcopy(dt_boxes[bno]) img_crop = self.get_rotate_crop_image(img, tmp_box) @@ -69,7 +69,6 @@ class TextSystemHelper(TextSystem): feed, fetch, self.tmp_args = self.text_classifier.preprocess( img_crop_list) fetch_map = self.clas_client.predict(feed, fetch) - print(fetch_map) outputs = [fetch_map[x] for x in self.text_classifier.fetch] for x in fetch_map.keys(): if ".lod" in x: @@ -104,7 +103,8 @@ class OCRService(WebService): rec_res = self.text_system.postprocess(outputs, self.tmp_args) res = { "pred_text": [x[0] for x in rec_res], - "score": [str(x[1]) for x in rec_res] + "score": [str(x[1]) for x in rec_res], + "pos": [x.tolist() for x in self.text_system.dt_boxes] } return res