Document Question Answering
Transformers
PyTorch
English
document-processing
ocr
ner
text-classification
information-extraction
invoice
receipt
form
Instructions to use mrrobot2610/IDP-Machine-learning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrrobot2610/IDP-Machine-learning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("document-question-answering", model="mrrobot2610/IDP-Machine-learning")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrrobot2610/IDP-Machine-learning", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download test_easyocr.py from mrrobot2610/IDP-Machine-learning: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/mrrobot2610/IDP-Machine-learning/resolve/main/test_easyocr.py
- Command line
-
hf download hf://mrrobot2610/IDP-Machine-learning/test_easyocr.py
-
curl -L -o test_easyocr.py https://huggingface.co/mrrobot2610/IDP-Machine-learning/resolve/main/test_easyocr.py
1.59 kB
| #!/usr/bin/env python3 | |
| """ | |
| Test EasyOCR initialization and functionality | |
| """ | |
| # Fix for TensorFlow mutex warnings on macOS | |
| import os | |
| os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE' | |
| os.environ['OMP_NUM_THREADS'] = '1' | |
| os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' | |
| import warnings | |
| warnings.filterwarnings('ignore') | |
| import sys | |
| import numpy as np | |
| import cv2 | |
| print("Testing EasyOCR integration...") | |
| print("=" * 60) | |
| try: | |
| from ocr_engine import LightweightOCR | |
| print("\n1. Importing LightweightOCR... β") | |
| print("\n2. Initializing EasyOCR engine...") | |
| ocr = LightweightOCR(lang='en', use_gpu=False) | |
| print(" β EasyOCR initialized successfully!") | |
| print("\n3. Creating dummy image for testing...") | |
| # Create a white image with black text "Hello World" | |
| image = np.ones((100, 300, 3), dtype=np.uint8) * 255 | |
| cv2.putText(image, 'Hello World', (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) | |
| print(" β Dummy image created") | |
| print("\n4. Running OCR extraction...") | |
| result = ocr.extract_text(image) | |
| print(f" β Extraction complete!") | |
| print(f" Extracted text: '{result['text']}'") | |
| if "Hello" in result['text'] or "World" in result['text']: | |
| print(" β Text verification passed!") | |
| else: | |
| print(" β Text verification warning: Expected 'Hello World', got something else") | |
| print("\n" + "=" * 60) | |
| print("β ALL TESTS PASSED!") | |
| print("=" * 60) | |
| except Exception as e: | |
| print(f"\nβ ERROR: {str(e)}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |