Spaces:
Sleeping
Sleeping
Download run_test.py from vamsi1103/flask-ocr-api: direct link, hf CLI and curl.
- Browser
- Download file 645 Bytes
-
https://huggingface.co/spaces/vamsi1103/flask-ocr-api/resolve/main/run_test.py
- Command line
-
hf download hf://spaces/vamsi1103/flask-ocr-api/run_test.py
-
curl -L -o run_test.py https://huggingface.co/spaces/vamsi1103/flask-ocr-api/resolve/main/run_test.py
645 Bytes
| import json | |
| import io | |
| import sys | |
| from PIL import Image | |
| from app.ocr_engine import run_ocr | |
| from app.parser import parse_ocr_results | |
| img_path = r"C:\Users\USER\.gemini\antigravity-ide\brain\695a8dea-df49-472d-925c-a43945b4677b\.user_uploaded\media_1791360104161.jpg" | |
| img = Image.open(img_path).convert("RGB") | |
| print("Running OCR on image...") | |
| raw = run_ocr(img) | |
| print(f"Detected {len(raw)} text fragments.") | |
| parsed = parse_ocr_results(raw) | |
| with open("test_output.json", "w", encoding="utf-8") as f: | |
| json.dump(parsed, f, ensure_ascii=False, indent=2) | |
| print(f"Parsed {len(parsed['items'])} items.") | |
| print(f"Extracted date: {parsed['date']}") | |