mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
* 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
21 lines
596 B
Python
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")
|