#!/usr/bin/env python3 """ Verify if chart recognition can be enabled in the current PaddlePaddle version Run this in the conda environment: conda activate tool_ocr && python verify_chart_recognition.py """ import sys def check_paddle_api(): """Check if fused_rms_norm_ext API is available""" try: import paddle print(f"āœ… PaddlePaddle version: {paddle.__version__}") # Check if the API exists import paddle.incubate.nn.functional as F has_base = hasattr(F, 'fused_rms_norm') has_ext = hasattr(F, 'fused_rms_norm_ext') print(f"\nšŸ“Š API Availability:") print(f" - fused_rms_norm: {'āœ… Available' if has_base else 'āŒ Not found'}") print(f" - fused_rms_norm_ext: {'āœ… Available' if has_ext else 'āŒ Not found'}") if has_ext: print(f"\nšŸŽ‰ Chart recognition CAN be enabled!") print(f"\nšŸ“ Action required:") print(f" 1. Edit backend/app/services/ocr_service.py") print(f" 2. Change line 217: use_chart_recognition=False → True") print(f" 3. Restart the backend service") print(f"\nāš ļø Note: This will enable deep chart analysis (may increase processing time)") return True else: print(f"\nāŒ Chart recognition CANNOT be enabled yet") print(f"\nšŸ“ Current PaddlePaddle version ({paddle.__version__}) does not support fused_rms_norm_ext") print(f"\nšŸ’” Options:") print(f" 1. Upgrade PaddlePaddle: pip install --upgrade paddlepaddle>=3.2.0") print(f" 2. Check for newer versions: pip search paddlepaddle") print(f" 3. Wait for official PaddlePaddle update") return False except ImportError as e: print(f"āŒ PaddlePaddle not installed: {e}") print(f"\nšŸ’” Install PaddlePaddle:") print(f" pip install paddlepaddle>=3.2.0") return False except Exception as e: print(f"āŒ Error: {e}") return False if __name__ == "__main__": print("=" * 70) print("Chart Recognition Availability Checker") print("=" * 70) print() can_enable = check_paddle_api() print() print("=" * 70) sys.exit(0 if can_enable else 1)