""" Verification script for Camera Models Explorer setup Checks all dependencies and system requirements """ import sys import subprocess def check_python_version(): """Check Python version""" print("šŸ Checking Python version...") version = sys.version_info if version.major == 3 and version.minor >= 11: print(f" āœ… Python {version.major}.{version.minor}.{version.micro} - OK") return True else: print(f" āŒ Python {version.major}.{version.minor} - Need 3.11+") return False def check_package(package_name, import_name=None): """Check if a package is installed""" if import_name is None: import_name = package_name try: __import__(import_name) print(f" āœ… {package_name} - OK") return True except ImportError: print(f" āŒ {package_name} - NOT FOUND") return False def check_dependencies(): """Check all required Python packages""" print("\nšŸ“¦ Checking Python dependencies...") packages = [ ("streamlit", "streamlit"), ("numpy", "numpy"), ("OpenCV", "cv2"), ("Pillow", "PIL"), ("matplotlib", "matplotlib"), ("huggingface_hub", "huggingface_hub"), ] results = [] for pkg_name, import_name in packages: results.append(check_package(pkg_name, import_name)) return all(results) def check_streamlit(): """Check if streamlit can import core components""" print("\nšŸŽØ Checking Streamlit functionality...") try: import streamlit as st print(" āœ… Streamlit imports - OK") return True except Exception as e: print(f" āŒ Streamlit error: {e}") return False def check_cv2(): """Check OpenCV functionality""" print("\nšŸ“· Checking OpenCV functionality...") try: import cv2 import numpy as np # Try basic operations test_img = np.zeros((100, 100, 3), dtype=np.uint8) result = cv2.cvtColor(test_img, cv2.COLOR_BGR2RGB) print(" āœ… OpenCV operations - OK") return True except Exception as e: print(f" āŒ OpenCV error: {e}") return False def check_huggingface(): """Check HuggingFace Hub functionality""" print("\nšŸ¤— Checking Hugging Face Hub...") try: from huggingface_hub import hf_hub_download, list_repo_files print(" āœ… Hugging Face Hub imports - OK") return True except Exception as e: print(f" āŒ Hugging Face Hub error: {e}") return False def main(): """Run all checks""" print("=" * 50) print("šŸ“· Camera Models Explorer - Setup Verification") print("=" * 50) checks = [ ("Python Version", check_python_version), ("Dependencies", check_dependencies), ("Streamlit", check_streamlit), ("OpenCV", check_cv2), ("Hugging Face Hub", check_huggingface), ] results = [] for name, check_fn in checks: try: result = check_fn() results.append(result) except Exception as e: print(f"\nāŒ Error checking {name}: {e}") results.append(False) print("\n" + "=" * 50) if all(results): print("āœ… All checks passed! You're ready to run the app.") print("\nStart the app with:") print(" make run") print("or") print(" streamlit run app.py") return 0 else: print("āŒ Some checks failed. Please install missing dependencies:") print(" pip install -r requirements.txt") return 1 if __name__ == "__main__": sys.exit(main())