Download python/ocr.py from mohameddalii/ocr-mt-5090: direct link, hf CLI and curl.
- Browser
- Download file 722 Bytes
-
https://huggingface.co/mohameddalii/ocr-mt-5090/resolve/main/python/ocr.py
- Command line
-
hf download hf://mohameddalii/ocr-mt-5090/python/ocr.py
-
curl -L -o ocr.py https://huggingface.co/mohameddalii/ocr-mt-5090/resolve/main/python/ocr.py
722 Bytes
| #!/usr/bin/env python3 | |
| """OCR an image via the local PaddleOCR-VL server.""" | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | |
| from ocr_engine import DEFAULT_BASE_URL, DEFAULT_MODEL, OcrEngine | |
| def main() -> int: | |
| p = argparse.ArgumentParser() | |
| p.add_argument("image", type=Path) | |
| p.add_argument("--base-url", default=DEFAULT_BASE_URL) | |
| p.add_argument("--model", default=DEFAULT_MODEL) | |
| args = p.parse_args() | |
| text, dt, _ = OcrEngine(args.base_url, args.model).ocr_image(args.image) | |
| print(text) | |
| print(f"\n# {dt:.2f}s", file=sys.stderr) | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |