Download examples/rapidocr_page.py from ScienceSoft/scnsoft-ocr-rec-multilingual: direct link, hf CLI and curl.
- Browser
- Download file 694 Bytes
-
https://huggingface.co/ScienceSoft/scnsoft-ocr-rec-multilingual/resolve/main/examples/rapidocr_page.py
- Command line
-
hf download hf://ScienceSoft/scnsoft-ocr-rec-multilingual/examples/rapidocr_page.py
-
curl -L -o rapidocr_page.py https://huggingface.co/ScienceSoft/scnsoft-ocr-rec-multilingual/resolve/main/examples/rapidocr_page.py
694 Bytes
| """Read a whole page/screenshot: RapidOCR's detector + this recogniser. | |
| pip install rapidocr_onnxruntime==1.4.4 opencv-python-headless huggingface_hub | |
| python rapidocr_page.py screenshot.png | |
| """ | |
| import sys | |
| from huggingface_hub import hf_hub_download | |
| from rapidocr_onnxruntime import RapidOCR | |
| REPO = "ScienceSoft/scnsoft-ocr-rec-multilingual" | |
| def main() -> None: | |
| engine = RapidOCR( | |
| rec_model_path=hf_hub_download(REPO, "rec-multi.onnx"), | |
| rec_keys_path=hf_hub_download(REPO, "dict-multi.txt"), | |
| ) | |
| result, _ = engine(sys.argv[1]) | |
| for _box, text, score in result or []: | |
| print(f"{float(score):.2f} {text}") | |
| if __name__ == "__main__": | |
| main() | |