""" Test Working Description: ComfyUI custom node for PDF tools and media processing Author: Eric Hiss (GitHub: EricRollei) Contact: eric@historic.camera, eric@rollei.us License: Dual License (Non-Commercial and Commercial Use) Copyright (c) 2025 Eric Hiss. All rights reserved. Dual License: 1. Non-Commercial Use: This software is licensed under the terms of the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ 2. Commercial Use: For commercial use, a separate license is required. Please contact Eric Hiss at eric@historic.camera or eric@rollei.us for licensing options. Dependencies: This code depends on several third-party libraries, each with its own license. See CREDITS.md for a comprehensive list of dependencies and their licenses. Third-party code: - See CREDITS.md for complete list of dependencies """ # Update test_working.py with path configuration: import os import sys from PIL import Image, ImageDraw # Add current directory to path current_dir = os.path.dirname(os.path.abspath(__file__)) if current_dir not in sys.path: sys.path.insert(0, current_dir) print(f"šŸ” Working Test Script") print(f" Current dir: {current_dir}") # Configure ComfyUI path for testing COMFYUI_PATH = "A:\\Comfy_Dec\\ComfyUI" print(f"šŸ”§ Setting ComfyUI path for testing: {COMFYUI_PATH}") # Test step by step print(f"\n1ļøāƒ£ Testing Florence2 Direct Import:") try: from florence2_detector import Florence2RectangleDetector, BoundingBox print('āœ… Florence2 direct import successful') florence2_available = True except Exception as e: print(f'āŒ Florence2 direct import failed: {e}') florence2_available = False print(f"\n2ļøāƒ£ Testing Surya Import:") try: from surya.layout import LayoutPredictor print('āœ… Surya import successful') surya_available = True except Exception as e: print(f'āŒ Surya import failed: {e}') surya_available = False print(f"\n3ļøāƒ£ Testing Analysis Engine:") try: from analysis_engine import ContentAnalysisEngine, analyze_for_pdf_extraction, set_comfyui_base_path print('āœ… Analysis engine import successful') # Set the correct ComfyUI path for testing if set_comfyui_base_path(COMFYUI_PATH): print('āœ… ComfyUI path configured successfully') else: print('āš ļø ComfyUI path configuration failed, models may not load') # Create engine with available components engine = ContentAnalysisEngine( enable_florence2=florence2_available, enable_surya=surya_available, enable_ocr=True, debug_mode=True ) print('āœ… Analysis engine created successfully') # Test with simple image test_image = Image.new('RGB', (800, 600), color='white') draw = ImageDraw.Draw(test_image) draw.rectangle([100, 100, 300, 200], outline='red', width=3) draw.text((110, 110), "Test text", fill='black') print(f"\n4ļøāƒ£ Testing Analysis:") result = engine.analyze_image_comprehensive(test_image) print(f"šŸ“Š Analysis Results:") print(f" Surya regions: {len(result.get('surya_layout', []))}") print(f" Florence2 rectangles: {len(result.get('florence2_rectangles', []))}") print(f" Analysis methods: {result.get('analysis_summary', {}).get('analysis_methods', [])}") # Test the convenience function too print(f"\n5ļøāƒ£ Testing Convenience Function:") result2 = analyze_for_pdf_extraction(test_image, debug_mode=True) print(f" Result keys: {list(result2.keys())}") print(f" Florence2 rectangles: {len(result2.get('florence2_rectangles', []))}") print(f"\nšŸŽ‰ All tests passed!") except Exception as e: print(f'āŒ Analysis engine test failed: {e}') import traceback traceback.print_exc()