Browse Source

增加测试逻辑

root 1 year ago
parent
commit
22818e5173

BIN
deploy/docker_compose/ + 'contrast_' + 1.png


BIN
deploy/docker_compose/img_test/test_img-0.png


BIN
deploy/docker_compose/img_test/test_img-1.png


BIN
deploy/docker_compose/img_test/test_img-10.png


BIN
deploy/docker_compose/img_test/test_img-11.png


BIN
deploy/docker_compose/img_test/test_img-12.png


BIN
deploy/docker_compose/img_test/test_img-13.png


BIN
deploy/docker_compose/img_test/test_img-14.png


BIN
deploy/docker_compose/img_test/test_img-15.png


BIN
deploy/docker_compose/img_test/test_img-16.png


BIN
deploy/docker_compose/img_test/test_img-17.png


BIN
deploy/docker_compose/img_test/test_img-18.png


BIN
deploy/docker_compose/img_test/test_img-19.png


BIN
deploy/docker_compose/img_test/test_img-2.png


BIN
deploy/docker_compose/img_test/test_img-3.png


BIN
deploy/docker_compose/img_test/test_img-4.png


BIN
deploy/docker_compose/img_test/test_img-5.png


BIN
deploy/docker_compose/img_test/test_img-6.png


BIN
deploy/docker_compose/img_test/test_img-7.png


BIN
deploy/docker_compose/img_test/test_img-8.png


BIN
deploy/docker_compose/img_test/test_img-9.png


+ 17 - 7
deploy/docker_compose/server.py

@@ -12,8 +12,9 @@ import base64
 import io
 import requests
 import json
+from pathlib import Path
 
-ocr = PaddleOCR(use_angle_cls=True, lang="ch", use_gpu=False)
+# ocr = PaddleOCR(use_angle_cls=True, lang="ch", use_gpu=False)
 app = Flask(__name__)
 img_dir = Path('imgs')
 img_dir.mkdir(exist_ok=True)
@@ -241,9 +242,18 @@ def get_file_from_url(url_file: str, target_path: str):
     return target_path
 
 if __name__ == '__main__':
-    port = os.environ.get('FLASK_PORT', '')
-    if port.isalnum() and int(port) > 0:
-        port = int(port)
-    else:
-        port = 5000
-    app.run(host='0.0.0.0', port=port, debug=True)
+    # port = os.environ.get('FLASK_PORT', '')
+    # if port.isalnum() and int(port) > 0:
+    #     port = int(port)
+    # else:
+    #     port = 5000
+    # app.run(host='0.0.0.0', port=port, debug=True)
+    test_dir = Path('img_test')
+    count = 1
+    start = time.perf_counter()
+    for file in test_dir.iterdir():
+        st = time.perf_counter()
+        result = ocr.ocr(str(file), cls=True)
+        print(f'第{count}张图片耗时:{format(time.perf_counter() - st)}')
+        count += 1
+    print(f'20张图片总耗时:{format(time.perf_counter() - start)}')

+ 2 - 2
paddleocr.py

@@ -497,7 +497,7 @@ class PaddleOCR(predict_system.TextSystem):
             params.rec_char_dict_path = str(
                 Path(__file__).parent / rec_model_config['dict_path'])
 
-        logger.debug(params)
+        # logger.debug(params)
         # init det_model and rec_model
         super().__init__(params)
         self.page_num = params.page_num
@@ -616,7 +616,7 @@ class PPStructure(StructureSystem):
         if params.layout_dict_path is None:
             params.layout_dict_path = str(
                 Path(__file__).parent / layout_model_config['dict_path'])
-        logger.debug(params)
+        # logger.debug(params)
         super().__init__(params)
 
     def __call__(self, img, return_ocr_result_in_table=False, img_idx=0):