|
|
|
""" |
|
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)" |
|
} |
|
|
|
|
|
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": |
|
missing_packages.append(package) |
|
|
|
|
|
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...") |
|
|
|
|
|
try: |
|
import whisper |
|
print("β
Whisper available for audio transcription") |
|
except ImportError: |
|
print("β οΈ Whisper not available (will be installed on first use)") |
|
|
|
|
|
try: |
|
from diffusers import StableDiffusionXLPipeline |
|
print("β
SDXL support available") |
|
except ImportError: |
|
print("β οΈ SDXL not available (requires newer diffusers)") |
|
|
|
|
|
try: |
|
from diffusers import StableDiffusionControlNetPipeline |
|
print("β
ControlNet available") |
|
except ImportError: |
|
print("β οΈ ControlNet not available") |
|
|
|
|
|
try: |
|
from diffusers import StableDiffusionLatentUpscalePipeline |
|
print("β
Latent Upscaler available") |
|
except ImportError: |
|
print("β οΈ Latent Upscaler not available") |
|
|
|
|
|
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_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") |
|
|
|
|
|
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() |
|
|
|
|
|
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 |
|
|
|
|
|
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 |
|
|
|
|
|
has_gpu = check_gpu_setup() |
|
|
|
|
|
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() |
|
|
|
|
|
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) |
|
|