test_gpu.py 471 B

12345678910111213141516
  1. from paddleocr import PaddleOCR
  2. from pathlib import Path
  3. import time
  4. ocr = PaddleOCR(use_angle_cls=True, lang="ch", rec=True, use_gpu=True)
  5. test_dir = Path('img_test')
  6. count = 1
  7. start = time.perf_counter()
  8. for file in test_dir.iterdir():
  9. st = time.perf_counter()
  10. result = ocr.ocr(str(file), cls=True)
  11. print(f'第{count}张图片耗时:{format(time.perf_counter() - st)}')
  12. count += 1
  13. print(f'20张图片总耗时:{format(time.perf_counter() - start)}')