| |
| """ |
| Test script for the FIXED pixeltext-ai model |
| """ |
|
|
| from transformers import AutoModel |
| from PIL import Image, ImageDraw, ImageFont |
|
|
| def test_fixed_model(): |
| """Test the fixed model.""" |
| |
| print("🧪 Testing FIXED pixeltext-ai model...") |
| |
| |
| model = AutoModel.from_pretrained("BabaK07/pixeltext-ai", trust_remote_code=True) |
| |
| |
| img = Image.new('RGB', (400, 200), color='white') |
| draw = ImageDraw.Draw(img) |
| |
| try: |
| font = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 20) |
| except: |
| font = ImageFont.load_default() |
| |
| draw.text((20, 50), "FIXED MODEL TEST", fill='black', font=font) |
| draw.text((20, 100), "Hub loading works!", fill='blue', font=font) |
| draw.text((20, 150), "from_pretrained success!", fill='green', font=font) |
| |
| |
| result = model.generate_ocr_text(img) |
| |
| print(f"📝 Results:") |
| print(f" Text: {result['text']}") |
| print(f" Confidence: {result['confidence']:.1%}") |
| print(f" Success: {result['success']}") |
| print(f" Method: {result['method']}") |
| |
| if result['success']: |
| print("✅ FIXED MODEL WORKING PERFECTLY!") |
| else: |
| print("❌ Still has issues") |
| |
| return result |
|
|
| if __name__ == "__main__": |
| test_fixed_model() |
|
|