Spaces:
Runtime error
Runtime error
Download ocr.py from bhoomee/TrustLensAI-fixed: direct link, hf CLI and curl.
- Browser
- Download file 504 Bytes
-
https://huggingface.co/spaces/bhoomee/TrustLensAI-fixed/resolve/main/ocr.py
- Command line
-
hf download hf://spaces/bhoomee/TrustLensAI-fixed/ocr.py
-
curl -L -o ocr.py https://huggingface.co/spaces/bhoomee/TrustLensAI-fixed/resolve/main/ocr.py
504 Bytes
| import pytesseract | |
| from PIL import Image | |
| # ============================== | |
| # TESSERACT PATH | |
| # ============================== | |
| pytesseract.pytesseract.tesseract_cmd = ( | |
| r"C:\Program Files\Tesseract-OCR\tesseract.exe" | |
| ) | |
| # ============================== | |
| # OCR TEXT EXTRACTION | |
| # ============================== | |
| def extract_text(image_path): | |
| image = Image.open( | |
| image_path | |
| ) | |
| text = pytesseract.image_to_string( | |
| image | |
| ) | |
| return text |