4. PaddleOCR - 테스트 1
2022. 6. 13. 15:44ㆍOCR/PaddleOCR
반응형
from paddleocr import PaddleOCR,draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese.
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
# to switch the language model in order.
ocr = PaddleOCR(use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
img_path = 'PaddleOCR-release-2.5/doc/imgs_en/img_12.jpg'
result = ocr.ocr(img_path, cls=True)
print("line=================================================")
for line in result:
print(line)
# draw result
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores, font_path='PaddleOCR-release-2.5/doc/fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result/test2result.jpg')
print("boxes=================================================")
print(boxes)
print("txts=================================================")
print(txts)
print("scores=================================================")
print(scores)
print("======================================================")
[원본]
[결과]
[로그]
PS D:\dev\workspace_py\paddleocr> d:; cd 'd:\dev\workspace_py\paddleocr'; & 'C:\Users\SolutionDev\anaconda3\envs\paddle_env\python.exe' 'c:\Users\SolutionDev\.vscode\extensions\ms-python.python-2022.8.0\pythonFiles\lib\python\debugpy\launcher' '55197' '--' 'd:\dev\workspace_py\paddleocr\test2.py'
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:36: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
'nearest': Image.NEAREST,
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:37: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
'bilinear': Image.BILINEAR,
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:38: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
'bicubic': Image.BICUBIC,
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:39: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.
'box': Image.BOX,
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:40: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
'lanczos': Image.LANCZOS,
C:\Users\SolutionDev\anaconda3\envs\paddle_env\lib\site-packages\paddle\vision\transforms\functional_pil.py:41: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.
'hamming': Image.HAMMING
[2022/06/13 15:05:18] ppocr DEBUG: Namespace(alpha=1.0, benchmark=False, beta=1.0, cls_batch_num=6, cls_image_shape='3, 48, 192', cls_model_dir='C:\\Users\\SolutionDev/.paddleocr/whl\\cls\\ch_ppocr_mobile_v2.0_cls_infer', cls_thresh=0.9, cpu_threads=10, crop_res_save_dir='./output', det=True, det_algorithm='DB', det_db_box_thresh=0.6, det_db_score_mode='fast', det_db_thresh=0.3, det_db_unclip_ratio=1.5, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_east_score_thresh=0.8, det_fce_box_type='poly', det_limit_side_len=960, det_limit_type='max', det_model_dir='C:\\Users\\SolutionDev/.paddleocr/whl\\det\\en\\en_PP-OCRv3_det_infer', det_pse_box_thresh=0.85, det_pse_box_type='quad', det_pse_min_area=16, det_pse_scale=1, det_pse_thresh=0, det_sast_nms_thresh=0.2, det_sast_polygon=False, det_sast_score_thresh=0.5, draw_img_save_dir='./inference_results', drop_score=0.5, e2e_algorithm='PGNet', e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_limit_side_len=768, e2e_limit_type='max', e2e_model_dir=None, e2e_pgnet_mode='fast', e2e_pgnet_score_thresh=0.5, e2e_pgnet_valid_set='totaltext', enable_mkldnn=False, fourier_degree=5, gpu_mem=500, help='==SUPPRESS==', image_dir=None, ir_optim=True, label_list=['0', '180'], lang='en', layout=True, layout_label_map=None, layout_path_model='lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config', max_batch_size=10, max_text_length=25, min_subgraph_size=15, mode='structure', ocr=True, ocr_version='PP-OCRv3', output='./output', precision='fp32', process_id=0, rec=True, rec_algorithm='SVTR_LCNet', rec_batch_num=6, rec_char_dict_path='C:\\Users\\SolutionDev\\anaconda3\\envs\\paddle_env\\lib\\site-packages\\paddleocr\\ppocr\\utils\\en_dict.txt', rec_image_shape='3, 48, 320', rec_model_dir='C:\\Users\\SolutionDev/.paddleocr/whl\\rec\\en\\en_PP-OCRv3_rec_infer', save_crop_res=False, save_log_path='./log_output/', scales=[8, 16, 32], show_log=True, structure_version='PP-STRUCTURE', table=True, table_char_dict_path=None, table_max_len=488, table_model_dir=None, total_process_num=1, type='ocr', use_angle_cls=True, use_dilation=False, use_gpu=True, use_mp=False, use_onnx=False, use_pdserving=False, use_space_char=True, use_tensorrt=False, vis_font_path='./doc/fonts/simfang.ttf', warmup=False)
[2022/06/13 15:05:21] ppocr DEBUG: dt_boxes num : 11, elapse : 1.421381950378418
[2022/06/13 15:05:21] ppocr DEBUG: cls num : 11, elapse : 0.02393627166748047
[2022/06/13 15:05:21] ppocr DEBUG: rec_res num : 11, elapse : 0.04188656806945801
line=================================================
[[[441.0, 174.0], [1166.0, 176.0], [1165.0, 222.0], [441.0, 221.0]], ('ACKNOWLEDGEMENTS', 0.9971132278442383)]
[[[403.0, 346.0], [1204.0, 348.0], [1204.0, 384.0], [402.0, 383.0]], ('We would like to thank all the designers and', 0.9761399626731873)]
[[[403.0, 396.0], [1204.0, 398.0], [1204.0, 434.0], [402.0, 433.0]], ('contributors who have been involved in the', 0.9791955351829529)]
[[[399.0, 446.0], [1207.0, 443.0], [1208.0, 484.0], [399.0, 488.0]], ('production of this book; their contributions', 0.9889590740203857)]
[[[401.0, 500.0], [1208.0, 500.0], [1208.0, 534.0], [401.0, 534.0]], ('have been indispensable to its creation. We', 0.9555091261863708)]
[[[399.0, 550.0], [1209.0, 548.0], [1209.0, 583.0], [399.0, 584.0]], ('would also like to express our gratitude to all', 0.9905331134796143)]
[[[399.0, 600.0], [1207.0, 598.0], [1208.0, 634.0], [399.0, 636.0]], ('the producers for their invaluable opinions', 0.9781713485717773)]
[[[399.0, 648.0], [1207.0, 646.0], [1208.0, 686.0], [399.0, 688.0]], ('and assistance throughout this project. And to', 0.9883643388748169)]
[[[399.0, 702.0], [1209.0, 698.0], [1209.0, 734.0], [399.0, 738.0]], ('the many others whose names are not credited', 0.9579494595527649)]
[[[399.0, 750.0], [1211.0, 750.0], [1211.0, 789.0], [399.0, 789.0]], ('but have made specific input in this book, we', 0.9702866673469543)]
[[[397.0, 802.0], [1090.0, 800.0], [1090.0, 839.0], [397.0, 841.0]], ('thank you for your continuous support.', 0.9978144764900208)]
boxes=================================================
[[[441.0, 174.0], [1166.0, 176.0], [1165.0, 222.0], [441.0, 221.0]], [[403.0, 346.0], [1204.0, 348.0], [1204.0, 384.0], [402.0, 383.0]], [[403.0, 396.0], [1204.0, 398.0], [1204.0, 434.0], [402.0, 433.0]], [[399.0, 446.0], [1207.0, 443.0], [1208.0, 484.0], [399.0, 488.0]], [[401.0, 500.0], [1208.0, 500.0], [1208.0, 534.0], [401.0, 534.0]], [[399.0, 550.0], [1209.0, 548.0], [1209.0, 583.0], [399.0, 584.0]], [[399.0, 600.0], [1207.0, 598.0], [1208.0, 634.0], [399.0, 636.0]], [[399.0, 648.0], [1207.0, 646.0], [1208.0, 686.0], [399.0, 688.0]], [[399.0, 702.0], [1209.0, 698.0], [1209.0, 734.0], [399.0, 738.0]], [[399.0, 750.0], [1211.0, 750.0], [1211.0, 789.0], [399.0, 789.0]], [[397.0, 802.0], [1090.0, 800.0], [1090.0, 839.0], [397.0, 841.0]]]
txts=================================================
['ACKNOWLEDGEMENTS', 'We would like to thank all the designers and', 'contributors who have been involved in the', 'production of this book; their contributions', 'have been indispensable to its creation. We', 'would also like to express our gratitude to all', 'the producers for their invaluable opinions', 'and assistance throughout this project. And to', 'the many others whose names are not credited', 'but have made specific input in this book, we', 'thank you for your continuous support.']
scores=================================================
[0.9971132278442383, 0.9761399626731873, 0.9791955351829529, 0.9889590740203857, 0.9555091261863708, 0.9905331134796143, 0.9781713485717773, 0.9883643388748169, 0.9579494595527649, 0.9702866673469543, 0.9978144764900208]
======================================================
반응형
'OCR > PaddleOCR' 카테고리의 다른 글
3. PaddleOCR - 샘플코드 실행 (0) | 2022.06.13 |
---|---|
2. PaddleOCR - 패키지설치 (0) | 2022.06.13 |
1. PaddleOCR - 개발환경 구성 (0) | 2022.06.13 |