CoolFace
Modelpublic

BabaK07/textract-ai

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
1likes8downloads
Model Card

textract-ai - FIXED VERSION โœ…

๐ŸŽ‰ FIXED: Hub loading now works properly!

A high-accuracy OCR model based on Qwen2-VL-2B-Instruct, now with proper Hugging Face Hub support.

โœ… What's Fixed

  • โ€”Hub Loading: AutoModel.from_pretrained() now works correctly
  • โ€”from_pretrained Method: Proper implementation added
  • โ€”Configuration: Fixed model configuration for Hub compatibility
  • โ€”Error Handling: Improved error handling and fallbacks

๐Ÿš€ Quick Start (NOW WORKS!)

python
from transformers import AutoModel
from PIL import Image

# Load model from Hub (FIXED!)
model = AutoModel.from_pretrained("BabaK07/textract-ai", trust_remote_code=True)

# Load image
image = Image.open("your_image.jpg")

# Extract text
result = model.generate_ocr_text(image, use_native=True)

print(f"Text: {result['text']}")
print(f"Confidence: {result['confidence']:.1%}")
print(f"Success: {result['success']}")

๐Ÿ“Š Performance

  • โ€”๐ŸŽฏ Accuracy: High accuracy OCR (up to 95% confidence)
  • โ€”โฑ๏ธ Speed: ~13 seconds per image (high quality)
  • โ€”๐ŸŒ Languages: Multi-language support
  • โ€”๐Ÿ’ป Device: CPU and GPU support
  • โ€”๐Ÿ“„ Documents: Excellent for complex documents

๐Ÿ› ๏ธ Features

  • โ€”โœ… Hub Loading: Works with AutoModel.from_pretrained()
  • โ€”โœ… High Accuracy: Based on Qwen2-VL-2B-Instruct
  • โ€”โœ… Multi-language: Supports many languages
  • โ€”โœ… Document OCR: Excellent for invoices, forms, documents
  • โ€”โœ… Robust Processing: Multiple extraction methods
  • โ€”โœ… Production Ready: Error handling included

๐Ÿ“ Usage Examples

Basic Usage

python
from transformers import AutoModel
from PIL import Image

model = AutoModel.from_pretrained("BabaK07/textract-ai", trust_remote_code=True)
image = Image.open("document.jpg")
result = model.generate_ocr_text(image, use_native=True)

High Accuracy Mode

python
result = model.generate_ocr_text(image, use_native=True)  # Best accuracy

Fast Mode

python
result = model.generate_ocr_text(image, use_native=False)  # Faster processing

File Path Input

python
result = model.generate_ocr_text("path/to/your/image.jpg")

๐Ÿ”ง Installation

bash
pip install torch transformers pillow

๐Ÿ“ˆ Model Details

  • โ€”Base Model: Qwen/Qwen2-VL-2B-Instruct
  • โ€”Model Size: ~2.5B parameters
  • โ€”Architecture: Vision-Language Transformer
  • โ€”Optimization: OCR-specific processing
  • โ€”Training: Custom OCR pipeline

๐Ÿ†š Comparison

FeatureBefore (Broken)After (FIXED)
Hub LoadingโŒ ValueErrorโœ… Works perfectly
from_pretrainedโŒ Missingโœ… Implemented
AutoModelโŒ Failedโœ… Compatible
ConfigurationโŒ Invalidโœ… Proper config

๐ŸŽฏ Use Cases

  • โ€”High-Accuracy OCR: When accuracy is most important
  • โ€”Document Processing: Complex invoices, forms, contracts
  • โ€”Multi-language Text: International documents
  • โ€”Professional OCR: Business and enterprise use
  • โ€”Research Applications: Academic and research projects

๐Ÿ”— Related Models

  • โ€”pixeltext-ai: https://huggingface.co/BabaK07/pixeltext-ai (PaliGemma-based, faster)
  • โ€”Base Model: https://huggingface.co/Qwen/Qwen2-VL-2B-Instruct

๐Ÿ“ž Support

For issues or questions, please check the model repository or contact the author.


Status: โœ… FIXED and ready for production use!