JoyCN commited on
Commit
fd26334
·
verified ·
1 Parent(s): 85f2557

docs: add system inference example with predict_system.py

Browse files
Files changed (1) hide show
  1. README.md +35 -0
README.md CHANGED
@@ -81,6 +81,41 @@ if isinstance(sd_rec, dict) and "state_dict" in sd_rec: sd_rec = sd_rec["state_d
81
  ```
82
 
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  ## Notes
85
 
86
  - Prefer the `huggingface_hub` API (`hf_hub_download`/`snapshot_download`) for reliable downloads and caching.
 
81
  ```
82
 
83
 
84
+ ## System Inference (predict_system.py)
85
+
86
+ Quick end-to-end OCR with PaddleOCR2Pytorch's system script.
87
+
88
+ 1) Clone code and install minimal deps (CPU example)
89
+
90
+ ```bash
91
+ git clone https://github.com/frotms/PaddleOCR2Pytorch.git
92
+ cd PaddleOCR2Pytorch
93
+ pip install -U torch opencv-python pillow pyyaml safetensors
94
+ ```
95
+
96
+ 2) Download weights and YAML (put in current folder)
97
+
98
+ ```bash
99
+ # Weights (recommended)
100
+ curl -L -o ptocr_v5_server_det.safetensors "https://huggingface.co/JoyCN/PaddleOCR-Pytorch/resolve/main/ptocr_v5_server_det.safetensors?download=true"
101
+ curl -L -o ptocr_v5_server_rec.safetensors "https://huggingface.co/JoyCN/PaddleOCR-Pytorch/resolve/main/ptocr_v5_server_rec.safetensors?download=true"
102
+
103
+ # Configs (YAML)
104
+ curl -L -o PP-OCRv5_server_det.yml "https://huggingface.co/JoyCN/PaddleOCR-Pytorch/resolve/main/PP-OCRv5_server_det.yml?download=true"
105
+ curl -L -o PP-OCRv5_server_rec.yml "https://huggingface.co/JoyCN/PaddleOCR-Pytorch/resolve/main/PP-OCRv5_server_rec.yml?download=true"
106
+ ```
107
+
108
+ 3) Run end-to-end detection + recognition
109
+
110
+ ```bash
111
+ python tools/infer/predict_system.py --use_gpu False --image_dir path/to/your_image.png --det_algorithm DB --det_yaml_path ./PP-OCRv5_server_det.yml --rec_yaml_path ./PP-OCRv5_server_rec.yml --det_model_path ./ptocr_v5_server_det.safetensors --rec_model_path ./ptocr_v5_server_rec.safetensors --rec_char_dict_path ./pytorchocr/utils/dict/ppocrv5_dict.txt --rec_algorithm SVTR --rec_image_shape "3,48,320" --draw_img_save_dir ./inference_results
112
+ ```
113
+
114
+ - Set `--use_gpu True` if you have a CUDA-ready environment.
115
+ - `--rec_image_shape "3,48,320"` is important for PP-OCRv5 recognition.
116
+ - Outputs: detection boxes, recognized text with scores, and a visualization image saved under `--draw_img_save_dir`.
117
+
118
+
119
  ## Notes
120
 
121
  - Prefer the `huggingface_hub` API (`hf_hub_download`/`snapshot_download`) for reliable downloads and caching.