FIX: Add proper test_fixed.py with from_pretrained support
Browse files- test_fixed.py +47 -0
test_fixed.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Test script for the FIXED pixeltext-ai model
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from transformers import AutoModel
|
| 7 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 8 |
+
|
| 9 |
+
def test_fixed_model():
|
| 10 |
+
"""Test the fixed model."""
|
| 11 |
+
|
| 12 |
+
print("🧪 Testing FIXED pixeltext-ai model...")
|
| 13 |
+
|
| 14 |
+
# Load model from Hub
|
| 15 |
+
model = AutoModel.from_pretrained("BabaK07/pixeltext-ai", trust_remote_code=True)
|
| 16 |
+
|
| 17 |
+
# Create test image
|
| 18 |
+
img = Image.new('RGB', (400, 200), color='white')
|
| 19 |
+
draw = ImageDraw.Draw(img)
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
font = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 20)
|
| 23 |
+
except:
|
| 24 |
+
font = ImageFont.load_default()
|
| 25 |
+
|
| 26 |
+
draw.text((20, 50), "FIXED MODEL TEST", fill='black', font=font)
|
| 27 |
+
draw.text((20, 100), "Hub loading works!", fill='blue', font=font)
|
| 28 |
+
draw.text((20, 150), "from_pretrained success!", fill='green', font=font)
|
| 29 |
+
|
| 30 |
+
# Extract text
|
| 31 |
+
result = model.generate_ocr_text(img)
|
| 32 |
+
|
| 33 |
+
print(f"📝 Results:")
|
| 34 |
+
print(f" Text: {result['text']}")
|
| 35 |
+
print(f" Confidence: {result['confidence']:.1%}")
|
| 36 |
+
print(f" Success: {result['success']}")
|
| 37 |
+
print(f" Method: {result['method']}")
|
| 38 |
+
|
| 39 |
+
if result['success']:
|
| 40 |
+
print("✅ FIXED MODEL WORKING PERFECTLY!")
|
| 41 |
+
else:
|
| 42 |
+
print("❌ Still has issues")
|
| 43 |
+
|
| 44 |
+
return result
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
test_fixed_model()
|