Spaces:
Build error
Build error
| """ | |
| Quick setup verification script for Video Highlight Extractor | |
| Run this to verify your installation is complete. | |
| """ | |
| import sys | |
| def check_dependencies(): | |
| """Check if all required dependencies are installed.""" | |
| print("π Checking dependencies...\n") | |
| dependencies = { | |
| 'streamlit': 'Streamlit framework', | |
| 'cv2': 'OpenCV', | |
| 'torch': 'PyTorch', | |
| 'transformers': 'Hugging Face Transformers', | |
| 'ultralytics': 'YOLOv8', | |
| 'clip': 'OpenAI CLIP', | |
| 'PIL': 'Pillow', | |
| 'numpy': 'NumPy', | |
| 'sklearn': 'scikit-learn' | |
| } | |
| missing = [] | |
| for module, name in dependencies.items(): | |
| try: | |
| if module == 'cv2': | |
| import cv2 | |
| elif module == 'clip': | |
| import clip | |
| else: | |
| __import__(module) | |
| print(f"β {name}") | |
| except ImportError: | |
| print(f"β {name} - NOT FOUND") | |
| missing.append(name) | |
| print() | |
| # Check optional dependencies | |
| print("π¦ Optional dependencies:") | |
| try: | |
| from decord import VideoReader | |
| print("β Decord (GPU-accelerated video decoding)") | |
| except ImportError: | |
| print("β οΈ Decord - Not installed (will use OpenCV fallback)") | |
| try: | |
| from scenedetect import detect | |
| print("β PySceneDetect (Scene detection)") | |
| except ImportError: | |
| print("β οΈ PySceneDetect - Not installed (will use fallback)") | |
| print() | |
| # Check CUDA | |
| print("π₯οΈ GPU Support:") | |
| try: | |
| import torch | |
| if torch.cuda.is_available(): | |
| print(f"β CUDA available - {torch.cuda.get_device_name(0)}") | |
| print(f" CUDA version: {torch.version.cuda}") | |
| else: | |
| print("β οΈ CUDA not available - Will use CPU") | |
| except: | |
| print("β οΈ Could not check CUDA status") | |
| print() | |
| # Check FFmpeg | |
| print("π¬ FFmpeg:") | |
| import subprocess | |
| try: | |
| result = subprocess.run( | |
| ['ffmpeg', '-version'], | |
| capture_output=True, | |
| text=True, | |
| timeout=5 | |
| ) | |
| if result.returncode == 0: | |
| version_line = result.stdout.split('\n')[0] | |
| print(f"β {version_line}") | |
| else: | |
| print("β FFmpeg found but error checking version") | |
| missing.append("FFmpeg (functional)") | |
| except FileNotFoundError: | |
| print("β FFmpeg - NOT FOUND in PATH") | |
| missing.append("FFmpeg") | |
| except Exception as e: | |
| print(f"β οΈ FFmpeg check failed: {e}") | |
| print("\n" + "="*60) | |
| if missing: | |
| print(f"\nβ Missing dependencies: {', '.join(missing)}") | |
| print("\nπ To install missing dependencies:") | |
| print(" pip install -r requirements.txt") | |
| if "FFmpeg" in missing: | |
| print("\nπ To install FFmpeg:") | |
| print(" Windows: choco install ffmpeg") | |
| print(" Linux: sudo apt-get install ffmpeg") | |
| print(" Mac: brew install ffmpeg") | |
| return False | |
| else: | |
| print("\nβ All required dependencies installed!") | |
| print("\nπ Ready to run:") | |
| print(" streamlit run app.py") | |
| return True | |
| def verify_structure(): | |
| """Verify project structure is complete.""" | |
| print("\n" + "="*60) | |
| print("\nπ Verifying project structure...\n") | |
| from pathlib import Path | |
| required_files = [ | |
| 'app.py', | |
| 'requirements.txt', | |
| 'README.md', | |
| 'pipeline/__init__.py', | |
| 'pipeline/ingest.py', | |
| 'pipeline/segmentation.py', | |
| 'pipeline/aesthetic.py', | |
| 'pipeline/objects.py', | |
| 'pipeline/vlm.py', | |
| 'pipeline/scoring.py', | |
| 'pipeline/selector.py', | |
| 'utils/__init__.py', | |
| 'utils/config.py', | |
| 'utils/video_utils.py', | |
| 'utils/similarity.py' | |
| ] | |
| required_dirs = [ | |
| 'outputs/frames', | |
| 'outputs/video' | |
| ] | |
| missing_files = [] | |
| for file in required_files: | |
| if Path(file).exists(): | |
| print(f"β {file}") | |
| else: | |
| print(f"β {file} - MISSING") | |
| missing_files.append(file) | |
| for dir_path in required_dirs: | |
| if Path(dir_path).exists(): | |
| print(f"β {dir_path}/") | |
| else: | |
| print(f"β {dir_path}/ - MISSING") | |
| missing_files.append(dir_path) | |
| print() | |
| if missing_files: | |
| print(f"β Missing files/directories: {len(missing_files)}") | |
| return False | |
| else: | |
| print("β All project files present!") | |
| return True | |
| if __name__ == "__main__": | |
| print("="*60) | |
| print("π¬ VIDEO HIGHLIGHT EXTRACTOR - Setup Verification") | |
| print("="*60) | |
| print() | |
| deps_ok = check_dependencies() | |
| structure_ok = verify_structure() | |
| print("\n" + "="*60) | |
| if deps_ok and structure_ok: | |
| print("\nπ Setup complete! Your application is ready to use.") | |
| print("\nπ Next steps:") | |
| print(" 1. Run: streamlit run app.py") | |
| print(" 2. Upload a video in the sidebar") | |
| print(" 3. Configure settings and click 'Extract Highlights'") | |
| print("\nπ See README.md for detailed documentation") | |
| else: | |
| print("\nβ οΈ Setup incomplete. Please address the issues above.") | |
| sys.exit(1) | |
| print("\n" + "="*60) | |