未验证 提交 849beb9a 编写于 作者: X xiaoting 提交者: GitHub

update pipeline to v3 (#6466)

* update pipeline to v3

* update pipeline to v3
上级 8bdb9d4e
...@@ -339,7 +339,7 @@ class CharacterOps(object): ...@@ -339,7 +339,7 @@ class CharacterOps(object):
class OCRReader(object): class OCRReader(object):
def __init__(self, def __init__(self,
algorithm="CRNN", algorithm="CRNN",
image_shape=[3, 32, 320], image_shape=[3, 48, 320],
char_type="ch", char_type="ch",
batch_num=1, batch_num=1,
char_dict_path="./ppocr_keys_v1.txt"): char_dict_path="./ppocr_keys_v1.txt"):
...@@ -356,7 +356,7 @@ class OCRReader(object): ...@@ -356,7 +356,7 @@ class OCRReader(object):
def resize_norm_img(self, img, max_wh_ratio): def resize_norm_img(self, img, max_wh_ratio):
imgC, imgH, imgW = self.rec_image_shape imgC, imgH, imgW = self.rec_image_shape
if self.character_type == "ch": if self.character_type == "ch":
imgW = int(32 * max_wh_ratio) imgW = int(imgH * max_wh_ratio)
h = img.shape[0] h = img.shape[0]
w = img.shape[1] w = img.shape[1]
ratio = w / float(h) ratio = w / float(h)
...@@ -377,7 +377,7 @@ class OCRReader(object): ...@@ -377,7 +377,7 @@ class OCRReader(object):
def preprocess(self, img_list): def preprocess(self, img_list):
img_num = len(img_list) img_num = len(img_list)
norm_img_batch = [] norm_img_batch = []
max_wh_ratio = 0 max_wh_ratio = 320/48.
for ino in range(img_num): for ino in range(img_num):
h, w = img_list[ino].shape[0:2] h, w = img_list[ino].shape[0:2]
wh_ratio = w * 1.0 / h wh_ratio = w * 1.0 / h
......
...@@ -63,7 +63,6 @@ class DetOp(Op): ...@@ -63,7 +63,6 @@ class DetOp(Op):
dt_boxes_list = self.post_func(det_out, [ratio_list]) 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]) 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} out_dict = {"dt_boxes": dt_boxes, "image": self.raw_im}
return out_dict, None, "" return out_dict, None, ""
...@@ -86,7 +85,7 @@ class RecOp(Op): ...@@ -86,7 +85,7 @@ class RecOp(Op):
dt_boxes = copy.deepcopy(self.dt_list) dt_boxes = copy.deepcopy(self.dt_list)
feed_list = [] feed_list = []
img_list = [] img_list = []
max_wh_ratio = 0 max_wh_ratio = 320/48.
## Many mini-batchs, the type of feed_data is list. ## Many mini-batchs, the type of feed_data is list.
max_batch_size = 6 # len(dt_boxes) max_batch_size = 6 # len(dt_boxes)
...@@ -150,7 +149,8 @@ class RecOp(Op): ...@@ -150,7 +149,8 @@ class RecOp(Op):
for i in range(dt_num): for i in range(dt_num):
text = rec_list[i] text = rec_list[i]
dt_box = self.dt_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)} res = {"result": str(result_list)}
return res, None, "" return res, None, ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册