π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
add release memory parameter
SWHL9590499f3b70
diff --git a/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py b/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.pyindex b226403..e6974ca 100644--- a/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py+++ b/ocrweb/resources/ch_ppocr_mobile_v2_cls/text_cls.py@@ -18,12 +18,12 @@ import timeimport cv2import numpy as np-import onnxruntime as ort+import onnxruntimetry:- from .utils import check_and_read_gif, get_image_file_list, ClsPostProcess+ from .utils import ClsPostProcess, check_and_read_gif, get_image_file_listexcept:- from utils import check_and_read_gif, get_image_file_list, ClsPostProcess+ from utils import ClsPostProcess, check_and_read_gif, get_image_file_listclass TextClassifier(object):@@ -32,7 +32,11 @@ class TextClassifier(object):self.cls_batch_num = 6self.cls_thresh = 0.9self.postprocess_op = ClsPostProcess(label_list=['0', '180'])- self.session = ort.InferenceSession(cls_model_path)++ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(cls_model_path, sess_opt)def resize_norm_img(self, img):imgC, imgH, imgW = self.cls_image_shapediff --git a/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py b/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.pyindex 78abb82..32673be 100644--- a/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py+++ b/ocrweb/resources/ch_ppocr_mobile_v2_det/text_detect.py@@ -56,7 +56,10 @@ class TextDetector(object):max_candidates=1000,unclip_ratio=2.0,use_dilation=True)- self.session = onnxruntime.InferenceSession(det_model_path)+ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(det_model_path, sess_opt)self.input_name = self.session.get_inputs()[0].nameself.output_name = self.session.get_outputs()[0].namediff --git a/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py b/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.pyindex 42a63db..54aece6 100644--- a/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py+++ b/ocrweb/resources/ch_ppocr_mobile_v2_rec/text_recognize.py@@ -41,7 +41,11 @@ class TextRecognizer(object):self.postprocess_op = CTCLabelDecode(self.character_dict_path,self.character_type,self.use_space_char)- self.session = onnxruntime.InferenceSession(rec_model_path)++ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(rec_model_path, sess_opt)def resize_norm_img(self, img, max_wh_ratio):img_channel, img_height, img_width = self.rec_image_shapediff --git a/python/ch_ppocr_mobile_v2_cls/text_cls.py b/python/ch_ppocr_mobile_v2_cls/text_cls.pyindex 8992ec4..e66b84f 100755--- a/python/ch_ppocr_mobile_v2_cls/text_cls.py+++ b/python/ch_ppocr_mobile_v2_cls/text_cls.py@@ -21,9 +21,9 @@ import numpy as npimport onnxruntime as orttry:- from .utils import check_and_read_gif, get_image_file_list, ClsPostProcess+ from .utils import ClsPostProcess, check_and_read_gif, get_image_file_listexcept:- from utils import check_and_read_gif, get_image_file_list, ClsPostProcess+ from utils import ClsPostProcess, check_and_read_gif, get_image_file_listclass TextClassifier(object):@@ -32,7 +32,11 @@ class TextClassifier(object):self.cls_batch_num = 6self.cls_thresh = 0.9self.postprocess_op = ClsPostProcess(label_list=['0', '180'])- self.session = ort.InferenceSession(cls_model_path)++ sess_opt = ort.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = ort.InferenceSession(cls_model_path, sess_opt)def resize_norm_img(self, img):imgC, imgH, imgW = self.cls_image_shapediff --git a/python/ch_ppocr_mobile_v2_det/text_detect.py b/python/ch_ppocr_mobile_v2_det/text_detect.pyindex e02fbff..87bb51a 100755--- a/python/ch_ppocr_mobile_v2_det/text_detect.py+++ b/python/ch_ppocr_mobile_v2_det/text_detect.py@@ -56,7 +56,10 @@ class TextDetector(object):max_candidates=1000,unclip_ratio=1.6,use_dilation=True)- self.session = onnxruntime.InferenceSession(det_model_path)+ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(det_model_path, sess_opt)self.input_name = self.session.get_inputs()[0].nameself.output_name = self.session.get_outputs()[0].namediff --git a/python/ch_ppocr_mobile_v2_rec/text_recognize.py b/python/ch_ppocr_mobile_v2_rec/text_recognize.pyindex 53ec726..baeee61 100755--- a/python/ch_ppocr_mobile_v2_rec/text_recognize.py+++ b/python/ch_ppocr_mobile_v2_rec/text_recognize.py@@ -36,7 +36,11 @@ class TextRecognizer(object):self.character_dict_path = str(root_path / 'ppocr_keys_v1.txt')self.postprocess_op = CTCLabelDecode(self.character_dict_path)- self.session = onnxruntime.InferenceSession(rec_model_path)++ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(rec_model_path, sess_opt)def resize_norm_img(self, img, max_wh_ratio):img_channel, img_height, img_width = self.rec_image_shapediff --git a/python/ch_ppocr_server_v2_det/text_detect.py b/python/ch_ppocr_server_v2_det/text_detect.pyindex a342a8c..d586766 100755--- a/python/ch_ppocr_server_v2_det/text_detect.py+++ b/python/ch_ppocr_server_v2_det/text_detect.py@@ -54,7 +54,10 @@ class TextDetector(object):unclip_ratio=1.6,use_dilation=True)- self.session = onnxruntime.InferenceSession(det_model_path)+ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(det_model_path, sess_opt)self.input_name = self.session.get_inputs()[0].nameself.output_name = self.session.get_outputs()[0].namediff --git a/python/ch_ppocr_server_v2_rec/text_recognize.py b/python/ch_ppocr_server_v2_rec/text_recognize.pyindex 5f1e799..894330f 100755--- a/python/ch_ppocr_server_v2_rec/text_recognize.py+++ b/python/ch_ppocr_server_v2_rec/text_recognize.py@@ -36,7 +36,11 @@ class TextRecognizer(object):self.character_dict_path = str(root_path / 'ppocr_keys_v1.txt')self.postprocess_op = CTCLabelDecode(self.character_dict_path)- self.session = onnxruntime.InferenceSession(rec_model_path)++ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(rec_model_path, sess_opt)def resize_norm_img(self, img, max_wh_ratio):img_channel, img_height, img_width = self.rec_image_shapediff --git a/python/inference_results/infer_1.jpg b/python/inference_results/infer_1.jpgdeleted file mode 100644index 0ba0b46..0000000Binary files a/python/inference_results/infer_1.jpg and /dev/null differdiff --git a/python/japan_ppocr_mobile_v2_rec/text_recognize.py b/python/japan_ppocr_mobile_v2_rec/text_recognize.pyindex ec398b3..e7877aa 100644--- a/python/japan_ppocr_mobile_v2_rec/text_recognize.py+++ b/python/japan_ppocr_mobile_v2_rec/text_recognize.py@@ -36,7 +36,11 @@ class TextRecognizer(object):self.character_dict_path = str(root_path / 'japan_dict.txt')self.postprocess_op = CTCLabelDecode(self.character_dict_path)- self.session = onnxruntime.InferenceSession(rec_model_path)++ sess_opt = onnxruntime.SessionOptions()+ sess_opt.log_severity_level = 4+ sess_opt.enable_cpu_mem_arena = False+ self.session = onnxruntime.InferenceSession(rec_model_path, sess_opt)def resize_norm_img(self, img, max_wh_ratio):img_channel, img_height, img_width = self.rec_image_shapediff --git a/python/rapidOCR.py b/python/rapidOCR.pyindex c733b97..b9f60ee 100644--- a/python/rapidOCR.py+++ b/python/rapidOCR.py@@ -16,6 +16,7 @@ drop_score = 0.5def str2bool(v):return v.lower() in ("true", "t", "1")+def check_and_read_gif(img_path):if Path(img_path).name[-3:] in ['gif', 'GIF']:gif = cv2.VideoCapture(img_path)