[Docs] Add example for switching to server models (#15320)

* Add example for switching to server models

* Add examples in quickstart
This commit is contained in:
Lin Manhui 2025-05-22 16:59:25 +08:00 committed by GitHub
parent 61e8f254d2
commit 0690815ce0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 2 deletions

View File

@ -65,11 +65,17 @@ pip install paddleocr==3.0.0
use_textline_orientation=False) # text detection + text recognition
# ocr = PaddleOCR(use_doc_orientation_classify=True, use_doc_unwarping=True) # text image preprocessing + text detection + textline orientation classification + text recognition
# ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False) # text detection + textline orientation classification + text recognition
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_server_det",
# text_recognition_model_name="PP-OCRv5_server_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False) # Switch to PP-OCRv5_server models
result = ocr.predict("./general_ocr_002.png")
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")
res.save_to_json("output")
```
Example output:

View File

@ -65,11 +65,17 @@ pip install paddleocr==3.0.0
use_textline_orientation=False) # 文本检测+文本识别
# ocr = PaddleOCR(use_doc_orientation_classify=True, use_doc_unwarping=True) # 文本图像预处理+文本检测+方向分类+文本识别
# ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False) # 文本检测+文本行方向分类+文本识别
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_server_det",
# text_recognition_model_name="PP-OCRv5_server_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False) # 更换 PP-OCRv5_server 模型
result = ocr.predict("./general_ocr_002.png")
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")
res.save_to_json("output")
```
输出示例:

View File

@ -945,6 +945,13 @@ ocr = PaddleOCR(
# ocr = PaddleOCR(lang="en") # Uses English model by specifying language parameter
# ocr = PaddleOCR(ocr_version="PP-OCRv4") # Uses other PP-OCR versions via version parameter
# ocr = PaddleOCR(device="gpu") # Enables GPU acceleration for model inference via device parameter
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_server_det",
# text_recognition_model_name="PP-OCRv5_server_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False,
# ) # Switch to PP-OCRv5_server models
result = ocr.predict("./general_ocr_002.png")
for res in result:
res.print()

View File

@ -945,6 +945,13 @@ ocr = PaddleOCR(
# ocr = PaddleOCR(lang="en") # 通过 lang 参数来使用英文模型
# ocr = PaddleOCR(ocr_version="PP-OCRv4") # 通过 ocr_version 参数来使用 PP-OCR 其他版本
# ocr = PaddleOCR(device="gpu") # 通过 device 参数使得在模型推理时使用 GPU
# ocr = PaddleOCR(
# text_detection_model_name="PP-OCRv5_server_det",
# text_recognition_model_name="PP-OCRv5_server_rec",
# use_doc_orientation_classify=False,
# use_doc_unwarping=False,
# use_textline_orientation=False,
# ) # 更换 PP-OCRv5_server 模型
result = ocr.predict("./general_ocr_002.png")
for res in result:
res.print()