Spaces:
Runtime error
Runtime error
| """ | |
| 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()) | |