mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-03 21:53:39 +08:00
[Cherry pick] update python serving for v3 (#6467)
* update pipeline to v3 * update pipeline to v3
This commit is contained in:
parent
d75b1229b3
commit
2dbdae6101
@ -339,7 +339,7 @@ class CharacterOps(object):
|
||||
class OCRReader(object):
|
||||
def __init__(self,
|
||||
algorithm="CRNN",
|
||||
image_shape=[3, 32, 320],
|
||||
image_shape=[3, 48, 320],
|
||||
char_type="ch",
|
||||
batch_num=1,
|
||||
char_dict_path="./ppocr_keys_v1.txt"):
|
||||
@ -356,7 +356,7 @@ class OCRReader(object):
|
||||
def resize_norm_img(self, img, max_wh_ratio):
|
||||
imgC, imgH, imgW = self.rec_image_shape
|
||||
if self.character_type == "ch":
|
||||
imgW = int(32 * max_wh_ratio)
|
||||
imgW = int(imgH * max_wh_ratio)
|
||||
h = img.shape[0]
|
||||
w = img.shape[1]
|
||||
ratio = w / float(h)
|
||||
@ -377,7 +377,7 @@ class OCRReader(object):
|
||||
def preprocess(self, img_list):
|
||||
img_num = len(img_list)
|
||||
norm_img_batch = []
|
||||
max_wh_ratio = 0
|
||||
max_wh_ratio = 320/48.
|
||||
for ino in range(img_num):
|
||||
h, w = img_list[ino].shape[0:2]
|
||||
wh_ratio = w * 1.0 / h
|
||||
|
@ -63,7 +63,6 @@ class DetOp(Op):
|
||||
dt_boxes_list = self.post_func(det_out, [ratio_list])
|
||||
dt_boxes = self.filter_func(dt_boxes_list[0], [self.ori_h, self.ori_w])
|
||||
out_dict = {"dt_boxes": dt_boxes, "image": self.raw_im}
|
||||
|
||||
return out_dict, None, ""
|
||||
|
||||
|
||||
@ -86,7 +85,7 @@ class RecOp(Op):
|
||||
dt_boxes = copy.deepcopy(self.dt_list)
|
||||
feed_list = []
|
||||
img_list = []
|
||||
max_wh_ratio = 0
|
||||
max_wh_ratio = 320/48.
|
||||
## Many mini-batchs, the type of feed_data is list.
|
||||
max_batch_size = 6 # len(dt_boxes)
|
||||
|
||||
@ -150,7 +149,8 @@ class RecOp(Op):
|
||||
for i in range(dt_num):
|
||||
text = rec_list[i]
|
||||
dt_box = self.dt_list[i]
|
||||
result_list.append([text, dt_box.tolist()])
|
||||
if text[1] >= 0.5:
|
||||
result_list.append([text, dt_box.tolist()])
|
||||
res = {"result": str(result_list)}
|
||||
return res, None, ""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user