diff --git a/ppocr/modeling/architectures/rec_model.py b/ppocr/modeling/architectures/rec_model.py index c54778fdccb76a5646eac5d8c172be8ef1136c3a..d88c620bdb44c9e3061ecbab9660866303c073db 100755 --- a/ppocr/modeling/architectures/rec_model.py +++ b/ppocr/modeling/architectures/rec_model.py @@ -109,6 +109,8 @@ class RecModel(object): decoded_out, 'label':label} return loader, outputs elif mode == "export": - return [image, {'decoded_out': decoded_out}] + predict = predicts['predict'] + predict = fluid.layers.softmax(predict) + return [image, {'decoded_out': decoded_out, 'predicts': predict}] else: return loader, {'decoded_out': decoded_out} diff --git a/ppocr/postprocess/db_postprocess.py b/ppocr/postprocess/db_postprocess.py index c7b2dbc1df6729d2cfa2beb71b157aff7a89e46f..3f6a051415545204e15192adf3bee96095474f73 100644 --- a/ppocr/postprocess/db_postprocess.py +++ b/ppocr/postprocess/db_postprocess.py @@ -81,7 +81,7 @@ class DBPostProcess(object): scores[index] = score return boxes, scores - def unclip(self, box, unclip_ratio=1.5): + def unclip(self, box, unclip_ratio=2.0): poly = Polygon(box) distance = poly.area * unclip_ratio / poly.length offset = pyclipper.PyclipperOffset() diff --git a/tools/export_model.py b/tools/export_model.py index 11a2744b399d6db2e1b07d258062ad1a47548ffb..04619bc53c7044d077ea48e77d5b0d1344db2e63 100644 --- a/tools/export_model.py +++ b/tools/export_model.py @@ -52,7 +52,8 @@ def main(): # check if set use_gpu=True in paddlepaddle cpu version use_gpu = config['Global']['use_gpu'] - program.check_gpu(True) + # program.check_gpu(True) + use_gpu = False alg = config['Global']['algorithm'] assert alg in ['EAST', 'DB', 'Rosetta', 'CRNN', 'STARNet', 'RARE'] diff --git a/tools/infer/predict_det.py b/tools/infer/predict_det.py index 07a8180fe028e852b86696b0da844fb55165e72a..85796fc561c15d53e2f43f0dd38281632613d92e 100755 --- a/tools/infer/predict_det.py +++ b/tools/infer/predict_det.py @@ -116,10 +116,10 @@ class TextDetector(object): rect_height = int(np.linalg.norm(box[0] - box[3])) if rect_width <= 10 or rect_height <= 10: continue - if diffh <= 10 and diffw <= 10: - box = self.expand_det_res( - copy.deepcopy(box), bbox_height, bbox_width, img_height, - img_width) + # if diffh <= 10 and diffw <= 10: + # box = self.expand_det_res( + # copy.deepcopy(box), bbox_height, bbox_width, img_height, + # img_width) dt_boxes_new.append(box) dt_boxes = np.array(dt_boxes_new) return dt_boxes diff --git a/tools/infer/predict_eval.py b/tools/infer/predict_eval.py index af0a5e2715d081a5c1c55ce9ea84d1984735596a..6f6f0730956cbb47295c0edb842410dfb401b765 100755 --- a/tools/infer/predict_eval.py +++ b/tools/infer/predict_eval.py @@ -38,6 +38,8 @@ if __name__ == "__main__": total_time_all = 0 count = 0 save_path = "./inference_output/predict.txt" + if not os.path.exists(os.path.dirname(save_path)): + os.makedirs(os.path.dirname(save_path)) fout = open(save_path, "wb") for image_name in image_file_list: image_file = image_name @@ -77,7 +79,10 @@ if __name__ == "__main__": draw_img_save = os.path.join( os.path.dirname(save_path), "inference_draw", os.path.basename(image_file)) - cv2.imwrite(draw_img_save, new_img) + if not os.path.exists(os.path.dirname(draw_img_save)): + os.makedirs(os.path.dirname(draw_img_save)) + cv2.imwrite(draw_img_save, new_img[:, :, ::-1]) + print("drawed img saved in {}".format(draw_img_save)) # save predicted results in txt file otstr = image_name + "\t" + json.dumps(bbox_list) + "\n" fout.write(otstr.encode('utf-8')) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index a8b0ebc001e0d9024ce7c131dc7ba376f333c626..7132ddfa08c4dc9b3fc60b9a5cd2e5b51336a3c9 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -138,7 +138,7 @@ def draw_ocr(image, boxes, txts, scores, draw_txt): for i, txt in enumerate(txts): font = ImageFont.truetype( - "/simfang.TTF", font_size, encoding="utf-8") + "./doc/simfang.TTF", font_size, encoding="utf-8") new_txt = str(i) + ': ' + txt + ' ' + str(scores[i]) draw_txt.text((20, gap * (i + 1)), new_txt, txt_color, font=font)