137 lines
4.4 KiB
Python
137 lines
4.4 KiB
Python
"""
|
|
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() |