#!/usr/bin/env python3 """ CompI Phase 3 Final Dashboard Launcher Launch the complete Phase 3 integrated dashboard that combines ALL CompI features: Phase 3.A/3.B: True multimodal fusion with real processing - Real audio transcription and analysis - Actual data processing and visualization - Sentiment analysis and emotion detection - Live real-time data feeds (weather, news) Phase 3.C: Advanced references with role assignment - Multi-image upload and URL support - Style vs structure role assignment - Live ControlNet previews (Canny/Depth) - Hybrid CN+I2I generation modes Phase 3.D: Professional workflow management - Gallery with advanced filtering - Rating, tagging, and annotation system - Preset save/load functionality - Complete export bundles with metadata Phase 3.E: Performance management and model switching - SD 1.5 โ†” SDXL model switching - LoRA integration with scale control - Performance optimizations (xFormers, attention slicing, VAE) - VRAM monitoring and OOM auto-retry - Optional latent upscaling Usage: python run_phase3_final_dashboard.py or streamlit run src/ui/compi_phase3_final_dashboard.py --server.port 8506 """ import os import sys import subprocess from pathlib import Path def check_dependencies(): """Check for required dependencies""" print("๐Ÿ“ฆ Checking dependencies...") required_packages = { "torch": "PyTorch", "diffusers": "Diffusers", "transformers": "Transformers", "accelerate": "Accelerate", "streamlit": "Streamlit", "pillow": "Pillow (PIL)", "numpy": "NumPy", "pandas": "Pandas", "librosa": "Librosa (audio processing)", "matplotlib": "Matplotlib (plotting)", "requests": "Requests (HTTP)", "feedparser": "FeedParser (RSS feeds)", "textblob": "TextBlob (sentiment analysis)" } # Special check for OpenCV (accept either opencv-python or opencv-python-headless) opencv_available = False try: import cv2 opencv_available = True required_packages["cv2"] = "OpenCV (image processing)" except ImportError: pass missing_packages = [] available_packages = [] for package, name in required_packages.items(): try: __import__(package.replace("-", "_")) available_packages.append(name) except ImportError: if package != "cv2": # cv2 already checked above missing_packages.append(package) # Add opencv to missing if not available if not opencv_available: missing_packages.append("opencv-python") print(f"โœ… Available: {', '.join(available_packages)}") if missing_packages: print(f"โŒ Missing: {', '.join(missing_packages)}") return False return True def check_optional_features(): """Check for optional features""" print("\n๐Ÿ” Checking optional features...") # Check Whisper try: import whisper print("โœ… Whisper available for audio transcription") except ImportError: print("โš ๏ธ Whisper not available (will be installed on first use)") # Check SDXL availability try: from diffusers import StableDiffusionXLPipeline print("โœ… SDXL support available") except ImportError: print("โš ๏ธ SDXL not available (requires newer diffusers)") # Check ControlNet availability try: from diffusers import StableDiffusionControlNetPipeline print("โœ… ControlNet available") except ImportError: print("โš ๏ธ ControlNet not available") # Check upscaler availability try: from diffusers import StableDiffusionLatentUpscalePipeline print("โœ… Latent Upscaler available") except ImportError: print("โš ๏ธ Latent Upscaler not available") # Check xFormers try: import xformers print("โœ… xFormers available for memory optimization") except ImportError: print("โš ๏ธ xFormers not available (optional performance boost)") def check_gpu_setup(): """Check GPU setup and provide recommendations""" print("\n๐Ÿ” Checking GPU setup...") try: import torch if torch.cuda.is_available(): gpu_count = torch.cuda.device_count() gpu_name = torch.cuda.get_device_name(0) total_memory = torch.cuda.get_device_properties(0).total_memory / (1024**3) print(f"โœ… CUDA available: {gpu_count} GPU(s)") print(f" Primary GPU: {gpu_name}") print(f" VRAM: {total_memory:.1f} GB") if total_memory >= 12.0: print("โœ… Excellent VRAM for all features including SDXL") elif total_memory >= 8.0: print("โœ… Good VRAM for SDXL and most features") elif total_memory >= 6.0: print("โœ… Sufficient VRAM for SD 1.5 and most features") print("โš ๏ธ SDXL may require optimizations") elif total_memory >= 4.0: print("โœ… Minimum VRAM for SD 1.5") print("โš ๏ธ Use aggressive optimizations for best performance") else: print("โš ๏ธ Limited VRAM - consider CPU mode or cloud GPU") return True else: print("โš ๏ธ CUDA not available - will use CPU mode") print("๐Ÿ’ก CPU mode is slower but still functional") return False except ImportError: print("โŒ PyTorch not found") return False def install_missing_dependencies(): """Install missing dependencies""" print("\n๐Ÿ“ฆ Installing missing dependencies...") try: # Core dependencies core_packages = [ "torch", "torchvision", "torchaudio", "diffusers>=0.21.0", "transformers", "accelerate", "streamlit", "pillow", "numpy", "pandas", "librosa", "opencv-python", "matplotlib", "requests", "feedparser", "textblob" ] print("Installing core packages...") subprocess.check_call([ sys.executable, "-m", "pip", "install" ] + core_packages) print("โœ… Core dependencies installed") # Optional performance packages (skip xformers due to compatibility issues) print("โš ๏ธ Skipping xFormers installation (compatibility issues with current PyTorch version)") return True except subprocess.CalledProcessError as e: print(f"โŒ Installation failed: {e}") return False def main(): """Launch Phase 3 Final Dashboard""" print("๐Ÿงช CompI Phase 3 Final Dashboard") print("=" * 80) print() print("๐ŸŽฏ Complete Phase 3 Integration (3.A โ†’ 3.E):") print(" โ€ข ๐Ÿงฉ Multimodal Inputs: Text, Audio, Data, Emotion, Real-time") print(" โ€ข ๐Ÿ–ผ๏ธ Advanced References: Role assignment, ControlNet, live previews") print(" โ€ข โš™๏ธ Model & Performance: SD 1.5/SDXL, LoRA, VRAM monitoring") print(" โ€ข ๐ŸŽ›๏ธ Intelligent Generation: Hybrid modes, OOM recovery") print(" โ€ข ๐Ÿ–ผ๏ธ Professional Gallery: Filtering, rating, annotation") print(" โ€ข ๐Ÿ’พ Preset Management: Save/load configurations") print(" โ€ข ๐Ÿ“ฆ Export System: Complete bundles with metadata") print() # Check if the UI file exists ui_file = Path("src/ui/compi_phase3_final_dashboard.py") if not ui_file.exists(): print(f"โŒ Error: {ui_file} not found!") print("Make sure you're running this from the project root directory.") return 1 # Check dependencies if not check_dependencies(): print("\nโŒ Missing dependencies detected.") install = input("Install missing dependencies? (y/n): ").lower().strip() if install == 'y': if not install_missing_dependencies(): print("โŒ Failed to install dependencies") return 1 else: print("โŒ Cannot proceed without required dependencies") return 1 # Check GPU setup has_gpu = check_gpu_setup() # Check optional features check_optional_features() print() print("๐Ÿš€ Launching Phase 3 Final Dashboard...") print("๐Ÿ“ Access at: http://localhost:8506") print() if has_gpu: print("๐Ÿ’ก GPU Tips:") print(" โ€ข Monitor VRAM usage in the top metrics bar") print(" โ€ข Use performance optimizations in Model & Performance tab") print(" โ€ข Enable OOM auto-retry for reliability") print(" โ€ข Try SDXL for higher quality (requires 8+ GB VRAM)") else: print("๐Ÿ’ก CPU Tips:") print(" โ€ข Generation will be slower but still functional") print(" โ€ข Use smaller image sizes (512x512 or less)") print(" โ€ข Reduce inference steps for faster generation") print(" โ€ข Stick to SD 1.5 model for best performance") print() print("๐ŸŽจ Getting Started:") print(" 1. ๐Ÿงฉ Configure multimodal inputs (audio, data, emotion, real-time)") print(" 2. ๐Ÿ–ผ๏ธ Upload reference images and assign roles (style vs structure)") print(" 3. โš™๏ธ Choose model and optimize performance settings") print(" 4. ๐ŸŽ›๏ธ Generate with intelligent fusion of all inputs") print(" 5. ๐Ÿ–ผ๏ธ Review results in gallery and add annotations") print(" 6. ๐Ÿ’พ Save presets for reuse") print(" 7. ๐Ÿ“ฆ Export complete bundles with metadata") print() # Launch Streamlit try: cmd = [ sys.executable, "-m", "streamlit", "run", str(ui_file), "--server.port", "8506", "--server.headless", "true", "--browser.gatherUsageStats", "false" ] subprocess.run(cmd) except KeyboardInterrupt: print("\n๐Ÿ‘‹ Phase 3 Final Dashboard stopped by user") return 0 except Exception as e: print(f"โŒ Error launching Streamlit: {e}") return 1 return 0 if __name__ == "__main__": exit_code = main() sys.exit(exit_code)