#!/usr/bin/env python3 """ 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...") # Load model from Hub model = AutoModel.from_pretrained("BabaK07/pixeltext-ai", trust_remote_code=True) # Create test image 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) # Extract text 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()