Files
rapidocr/python/demo.py
T
SWHL 787819457f fix: fixed issue #566 (#573)
* chore: update files

* chore: update files

* chore: refacter torch config

* chore: refacter torch infersession

* chore: refacter torch infersession

* test: change image url from github to modelscope
2025-11-07 20:00:33 +08:00

21 lines
596 B
Python

# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
from rapidocr import EngineType, RapidOCR
engine = RapidOCR(
params={
"Det.engine_type": EngineType.TORCH,
"Cls.engine_type": EngineType.TORCH,
"Rec.engine_type": EngineType.TORCH,
"EngineConfig.torch.use_cuda": True, # 使用torch GPU版推理
"EngineConfig.torch.gpu_id": 0, # 指定GPU id
}
)
img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
result = engine(img_url)
print(result)
result.vis("vis_result.jpg")