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 check_backend.py from mrrobot2610/IDP-Machine-learning: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/mrrobot2610/IDP-Machine-learning/resolve/main/check_backend.py
- Command line
-
hf download hf://mrrobot2610/IDP-Machine-learning/check_backend.py
-
curl -L -o check_backend.py https://huggingface.co/mrrobot2610/IDP-Machine-learning/resolve/main/check_backend.py
2.78 kB
| #!/usr/bin/env python3 | |
| """ | |
| Backend Diagnostic Tool | |
| ======================= | |
| Quick script to check if the backend is running and healthy. | |
| """ | |
| import requests | |
| import sys | |
| import time | |
| from typing import Optional | |
| class Colors: | |
| OKGREEN = '\033[92m' | |
| WARNING = '\033[93m' | |
| FAIL = '\033[91m' | |
| ENDC = '\033[0m' | |
| BOLD = '\033[1m' | |
| def check_backend(url: str = "http://localhost:7860", timeout: int = 30) -> bool: | |
| """Check if backend is running and healthy.""" | |
| health_url = f"{url}/health" | |
| print(f"{Colors.BOLD}Checking backend at {url}...{Colors.ENDC}\n") | |
| # Wait for backend to start | |
| print(f"Waiting for server to start (timeout: {timeout}s)...") | |
| start_time = time.time() | |
| while time.time() - start_time < timeout: | |
| try: | |
| response = requests.get(health_url, timeout=2) | |
| if response.status_code == 200: | |
| data = response.json() | |
| print(f"\n{Colors.OKGREEN}β Backend is running!{Colors.ENDC}") | |
| print(f"{Colors.OKGREEN}β Status: {data.get('status')}{Colors.ENDC}") | |
| print(f"{Colors.OKGREEN}β Models loaded: {data.get('models_loaded')}{Colors.ENDC}") | |
| print(f"{Colors.OKGREEN}β Version: {data.get('version')}{Colors.ENDC}") | |
| print(f"\n{Colors.BOLD}Available endpoints:{Colors.ENDC}") | |
| print(f" β’ Root: {url}/") | |
| print(f" β’ Health: {url}/health") | |
| print(f" β’ Process: {url}/process") | |
| print(f" β’ API Docs: {url}/docs") | |
| return True | |
| except requests.exceptions.RequestException: | |
| # Server not ready yet | |
| pass | |
| # Show progress | |
| elapsed = int(time.time() - start_time) | |
| print(f"\rWaiting... ({elapsed}s/{timeout}s)", end="", flush=True) | |
| time.sleep(1) | |
| print(f"\n\n{Colors.FAIL}β Backend is not responding{Colors.ENDC}") | |
| print(f"{Colors.WARNING}Possible issues:{Colors.ENDC}") | |
| print(" 1. Backend server not started") | |
| print(" 2. Taking longer than expected to load ML models") | |
| print(" 3. Port 7860 is blocked or in use") | |
| print(" 4. Missing dependencies") | |
| print(f"\n{Colors.BOLD}Troubleshooting steps:{Colors.ENDC}") | |
| print(" 1. Check if backend is running: ps aux | grep api_server.py") | |
| print(" 2. Check backend logs in the terminal where you started it") | |
| print(" 3. Try starting manually: python api_server.py") | |
| print(" 4. Check port availability: lsof -i :7860") | |
| return False | |
| def main(): | |
| """Main function.""" | |
| # Check default backend | |
| if check_backend(): | |
| sys.exit(0) | |
| else: | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |