@@ -647,10 +647,9 @@ RapidOCR输出包括4种类型:`Union[TextDetOutput, TextClsOutput, TextRecOut
647647
648648 - CPU版
649649
650- ```python linenums="1" hl_lines="4 "
650+ ```python linenums="1" hl_lines="3 "
651651 from rapidocr import RapidOCR
652652
653- # CPU版直接使用
654653 engine = RapidOCR(params={"Global.with_paddle": True})
655654
656655 img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
@@ -662,10 +661,9 @@ RapidOCR输出包括4种类型:`Union[TextDetOutput, TextClsOutput, TextRecOut
662661
663662 - GPU版
664663
665- ```python linenums="1" hl_lines="4 "
664+ ```python linenums="1" hl_lines="3-9 "
666665 from rapidocr import RapidOCR
667666
668- # GPU版,指定GPU id
669667 engine = RapidOCR(
670668 params={
671669 "Global.with_paddle": True,
@@ -704,27 +702,39 @@ RapidOCR输出包括4种类型:`Union[TextDetOutput, TextClsOutput, TextRecOut
704702
705703 2. 指定PyTorch作为推理引擎
706704
707- ```python linenums="1" hl_lines="4"
708- from rapidocr import RapidOCR
705+ - CPU版
709706
710- # CPU版直接使用
711- engine = RapidOCR(params={"Global.with_torch": True})
707+ ```python linenums="1" hl_lines="3"
708+ from rapidocr import RapidOCR
712709
713- # GPU版,指定GPU id
714- engine = RapidOCR(
715- params={
716- "Global.with_torch": True,
717- "EngineConfig.torch.use_cuda": True, # 使用torch GPU版推理
718- "EngineConfig.torch.gpu_id": 0, # 指定GPU id
719- }
720- )
710+ engine = RapidOCR(params={"Global.with_torch": True})
721711
722- img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
723- result = engine(img_url)
724- print(result)
712+ img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
713+ result = engine(img_url)
714+ print(result)
725715
726- result.vis('vis_result.jpg')
727- ```
716+ result.vis('vis_result.jpg')
717+ ```
718+
719+ - GPU版
720+
721+ ```python linenums="1" hl_lines="3-9"
722+ from rapidocr import RapidOCR
723+
724+ engine = RapidOCR(
725+ params={
726+ "Global.with_torch": True,
727+ "EngineConfig.torch.use_cuda": True, # 使用torch GPU版推理
728+ "EngineConfig.torch.gpu_id": 0, # 指定GPU id
729+ }
730+ )
731+
732+ img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
733+ result = engine(img_url)
734+ print(result)
735+
736+ result.vis('vis_result.jpg')
737+ ```
728738
729739 3. 查看输出日志。下面日志中打印出了**Using engine_name: torch**,则证明使用的推理引擎是PyTorch。
730740
0 commit comments