58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for PaddleOCR in CPU mode
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
print('🔍 Testing PaddleOCR with corrected parameters...')
|
|
try:
|
|
# Test PaddleOCR with correct parameter names
|
|
from paddleocr import PaddleOCR
|
|
|
|
print('✅ PaddleOCR imported successfully')
|
|
|
|
# Initialize OCR with correct parameters (no use_gpu parameter in this version)
|
|
ocr = PaddleOCR(use_textline_orientation=True, lang='en')
|
|
print('✅ PaddleOCR initialized successfully')
|
|
print('💡 Note: GPU mode requires cuDNN installation for CUDA 12.9')
|
|
|
|
# Test with a simple image path
|
|
test_image = 'test_ocr_image.png'
|
|
if os.path.exists(test_image):
|
|
print(f'✅ Test image found: {test_image}')
|
|
result = ocr.ocr(test_image, cls=True)
|
|
if result and len(result) > 0:
|
|
print('✅ OCR processing successful')
|
|
print(f' Detected {len(result[0])} text elements')
|
|
# Show first few results
|
|
for i, line in enumerate(result[0][:3]):
|
|
text = line[1][0]
|
|
confidence = line[1][1]
|
|
print(f' {i+1}. \"{text}\" (confidence: {confidence:.2f})')
|
|
else:
|
|
print('❌ OCR processing returned no results')
|
|
else:
|
|
print(f'⚠️ Test image not found: {test_image}')
|
|
print('💡 Testing OCR initialization only')
|
|
|
|
except Exception as e:
|
|
print(f'❌ PaddleOCR test failed: {e}')
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
print('\n🔍 Checking if OCR PDF exists...')
|
|
ocr_pdf_path = 'inputs/__enqueued__/ocr.pdf'
|
|
if os.path.exists(ocr_pdf_path):
|
|
print(f'✅ OCR PDF found: {ocr_pdf_path}')
|
|
print('💡 Ready to test OCR PDF upload')
|
|
else:
|
|
print(f'❌ OCR PDF not found: {ocr_pdf_path}')
|
|
print('💡 Please ensure ocr.pdf is in inputs/__enqueued__/ directory')
|
|
|
|
print('\n🔍 Summary:')
|
|
print('✅ PaddleOCR works in CPU mode')
|
|
print('❌ GPU acceleration requires cuDNN for CUDA 12.9')
|
|
print('💡 Download cuDNN from: https://developer.nvidia.com/cudnn')
|
|
print('💡 Extract to: C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.9\\bin\\') |