Download services/ocr.py from ZeloTech/zelotech: direct link, hf CLI and curl.
- Browser
- Download file 306 Bytes
-
https://huggingface.co/spaces/ZeloTech/zelotech/resolve/main/services/ocr.py
- Command line
-
hf download hf://spaces/ZeloTech/zelotech/services/ocr.py
-
curl -L -o ocr.py https://huggingface.co/spaces/ZeloTech/zelotech/resolve/main/services/ocr.py
306 Bytes
| import pytesseract | |
| from PIL import Image | |
| def ocr_image(image: Image.Image, lang: str = "por") -> str: | |
| return pytesseract.image_to_string(image, lang=lang) | |
| def ocr_image_path(path: str, lang: str = "por") -> str: | |
| with Image.open(path) as img: | |
| return ocr_image(img, lang=lang) | |