@@ -1287,24 +1287,26 @@ If `save_path` is specified, the visualization results will be saved under `save
12871287
12881288The command-line method is for quick testing. For project integration, you can achieve OCR inference with just a few lines of code:
12891289
1290- ``` python
1291- from paddleocr import PaddleOCR
1290+ ``` python
1291+ from paddleocr import PaddleOCR
12921292
1293+ # Uses PP-OCRv6 models by default
12931294ocr = PaddleOCR(
12941295 use_doc_orientation_classify = False , # Disables document orientation classification model via this parameter
12951296 use_doc_unwarping = False , # Disables text image rectification model via this parameter
12961297 use_textline_orientation = False , # Disables text line orientation classification model via this parameter
12971298)
12981299# ocr = PaddleOCR(lang="en") # Uses English model by specifying language parameter
1299- # ocr = PaddleOCR(ocr_version="PP-OCRv4") # Uses other PP-OCR versions via version parameter
1300+ # ocr = PaddleOCR(ocr_version="PP-OCRv5") # Switches to PP-OCRv5 version via ocr_version parameter
1301+ # ocr = PaddleOCR(ocr_version="PP-OCRv4") # Switches to PP-OCRv4 version via ocr_version parameter
13001302# ocr = PaddleOCR(device="gpu") # Enables GPU acceleration for model inference via device parameter
13011303# ocr = PaddleOCR(
13021304# text_detection_model_name="PP-OCRv5_mobile_det",
13031305# text_recognition_model_name="PP-OCRv5_mobile_rec",
13041306# use_doc_orientation_classify=False,
13051307# use_doc_unwarping=False,
13061308# use_textline_orientation=False,
1307- # ) # Switch to PP-OCRv5_mobile models
1309+ # ) # Switch to PP-OCRv5 mobile models
13081310result = ocr.predict(" ./general_ocr_002.png" )
13091311for res in result:
13101312 res.print()
@@ -2625,14 +2627,16 @@ If you choose `transformers` as the inference engine, make sure the Transformers
26252627``` python
26262628from paddleocr import PaddleOCR
26272629
2630+ # Uses PP-OCRv6 models by default
26282631ocr = PaddleOCR(
26292632 use_doc_orientation_classify = False , # Disable document orientation classification
26302633 use_doc_unwarping = False , # Disable document unwarping
26312634 use_textline_orientation = False , # Disable textline orientation classification
26322635 engine = " transformers" ,
26332636)
26342637# ocr = PaddleOCR(lang="en", engine="transformers") # Use the English model
2635- # ocr = PaddleOCR(ocr_version="PP-OCRv4", engine="transformers") # Use another PP-OCR version
2638+ # ocr = PaddleOCR(ocr_version="PP-OCRv5", engine="transformers") # Switch to PP-OCRv5 version
2639+ # ocr = PaddleOCR(ocr_version="PP-OCRv4", engine="transformers") # Switch to PP-OCRv4 version
26362640# ocr = PaddleOCR(device="gpu", engine="transformers") # Use GPU for inference
26372641# ocr = PaddleOCR(
26382642# text_detection_model_name="PP-OCRv5_server_det",
@@ -2641,7 +2645,7 @@ ocr = PaddleOCR(
26412645# use_doc_unwarping=False,
26422646# use_textline_orientation=False,
26432647# engine="transformers",
2644- # ) # Switch to the PP-OCRv5_server models
2648+ # ) # Switch to PP-OCRv5 server models
26452649result = ocr.predict(" ./general_ocr_002.png" )
26462650for res in result:
26472651 res.print()
@@ -2654,14 +2658,16 @@ If you choose `onnxruntime` as the inference engine, make sure the ONNX Runtime
26542658``` python
26552659from paddleocr import PaddleOCR
26562660
2661+ # Uses PP-OCRv6 models by default
26572662ocr = PaddleOCR(
26582663 use_doc_orientation_classify = False , # Disable document orientation classification
26592664 use_doc_unwarping = False , # Disable document unwarping
26602665 use_textline_orientation = False , # Disable textline orientation classification
26612666 engine = " onnxruntime" ,
26622667)
26632668# ocr = PaddleOCR(lang="en", engine="onnxruntime") # Use the English model
2664- # ocr = PaddleOCR(ocr_version="PP-OCRv4", engine="onnxruntime") # Use another PP-OCR version
2669+ # ocr = PaddleOCR(ocr_version="PP-OCRv5", engine="onnxruntime") # Switch to PP-OCRv5 version
2670+ # ocr = PaddleOCR(ocr_version="PP-OCRv4", engine="onnxruntime") # Switch to PP-OCRv4 version
26652671# ocr = PaddleOCR(device="gpu", engine="onnxruntime") # Use GPU for inference
26662672# ocr = PaddleOCR(
26672673# text_detection_model_name="PP-OCRv5_server_det",
@@ -2670,7 +2676,7 @@ ocr = PaddleOCR(
26702676# use_doc_unwarping=False,
26712677# use_textline_orientation=False,
26722678# engine="onnxruntime",
2673- # ) # Switch to the PP-OCRv5_server models
2679+ # ) # Switch to PP-OCRv5 server models
26742680result = ocr.predict(" ./general_ocr_002.png" )
26752681for res in result:
26762682 res.print()
0 commit comments