""" Check OpenCLIP virtual environment status """ import subprocess import sys import os def check_openclip_environment(): """Check if OpenCLIP virtual environment is working""" print("šŸ” Checking OpenCLIP Virtual Environment") print("=" * 50) venv_python = "openclip_env\\Scripts\\python.exe" if not os.path.exists(venv_python): print(f"āŒ Virtual environment not found: {venv_python}") return False print(f"āœ… Virtual environment found: {venv_python}") # Test basic Python functionality print("\nšŸ Testing Python in virtual environment...") result = subprocess.run([ venv_python, '-c', 'print("Python is working")' ], capture_output=True, text=True, encoding='utf-8', errors='ignore', timeout=10) if result.returncode == 0: print("āœ… Python is working in virtual environment") print(f" Output: {result.stdout.strip()}") else: print(f"āŒ Python test failed: {result.stderr}") return False # Test OpenCLIP import print("\n🧠 Testing OpenCLIP import...") result = subprocess.run([ venv_python, '-c', 'import open_clip; print(f"OpenCLIP version: {open_clip.__version__}")' ], capture_output=True, text=True, encoding='utf-8', errors='ignore', timeout=30) if result.returncode == 0: print("āœ… OpenCLIP import successful") print(f" {result.stdout.strip()}") else: print(f"āŒ OpenCLIP import failed: {result.stderr}") return False # Test PyTorch and CUDA print("\nšŸŽ® Testing PyTorch and CUDA...") result = subprocess.run([ venv_python, '-c', 'import torch; print(f"PyTorch version: {torch.__version__}"); print(f"CUDA available: {torch.cuda.is_available()}")' ], capture_output=True, text=True, encoding='utf-8', errors='ignore', timeout=30) if result.returncode == 0: print("āœ… PyTorch test successful") print(f" {result.stdout.strip()}") else: print(f"āŒ PyTorch test failed: {result.stderr}") return False return True def test_openclip_classification(): """Test OpenCLIP image classification""" print("\nšŸ–¼ļø Testing OpenCLIP Image Classification") print("=" * 50) venv_python = "openclip_env\\Scripts\\python.exe" # Test with one of the extracted images test_image = "extracted_images\\image1.png" if not os.path.exists(test_image): print(f"āŒ Test image not found: {test_image}") return print(f"šŸ“ø Testing with image: {test_image}") # Use the openclip_classifier.py script we created result = subprocess.run([ venv_python, 'openclip_classifier.py', test_image ], capture_output=True, text=True, encoding='utf-8', errors='ignore', timeout=60) if result.returncode == 0: print("āœ… OpenCLIP classification successful") print(f" Result: {result.stdout.strip()}") else: print(f"āŒ OpenCLIP classification failed: {result.stderr}") def check_paddleocr_status(): """Check PaddleOCR status in main environment""" print("\nšŸ”¤ Checking PaddleOCR Status") print("=" * 50) try: import paddleocr from paddleocr import PaddleOCR print("āœ… PaddleOCR imported successfully") # Try to initialize try: ocr = PaddleOCR(use_gpu=True) print("āœ… PaddleOCR GPU initialization successful") except Exception as e: print(f"āŒ PaddleOCR GPU initialization failed: {e}") print("āš ļø This might be due to CUDA conflicts with OpenCLIP") except ImportError as e: print(f"āŒ PaddleOCR import failed: {e}") def main(): """Run all checks""" print("šŸš€ COMPREHENSIVE DEPENDENCY CHECK") print("=" * 60) # Check OpenCLIP environment openclip_ok = check_openclip_environment() if openclip_ok: test_openclip_classification() # Check PaddleOCR check_paddleocr_status() print("\n" + "=" * 60) print("šŸ“‹ SUMMARY:") if openclip_ok: print("āœ… OpenCLIP virtual environment is working") print("āœ… Image classification pipeline is ready") else: print("āŒ OpenCLIP environment needs fixing") print("āœ… PaddleOCR dependency isolation implemented") if __name__ == "__main__": main()