| """ |
| profiles.py — Multiverse AI Studio Inference Control Panel |
| ============================================================ |
| WHAT: This file is the single source of truth for HOW each pipeline stage runs. |
| WHY: Instead of hunting through multiple model files to swap a backend or a model ID, |
| you change ONE thing here — the ACTIVE_PROFILE — and the entire pipeline adapts. |
| HOW: Each profile is a dictionary that maps a pipeline stage to its backend and model. |
| Model wrappers import their config from here instead of hardcoding their backends. |
| |
| === HOW TO SWITCH PROFILES === |
| Set the INFERENCE_PROFILE environment variable in your .env file: |
| |
| INFERENCE_PROFILE=gemini_cloud ← Default. Free, no GPU needed. |
| INFERENCE_PROFILE=huggingface ← Requires HF Inference Provider credits. |
| INFERENCE_PROFILE=local_gpu ← Requires NVIDIA GPU (8GB+ VRAM recommended). |
| INFERENCE_PROFILE=mock ← Instant mock assets. For UI development only. |
| |
| === BACKEND OPTIONS PER STAGE === |
| "gemini" → Google Gemini API (LLM text + image generation). Free quota. |
| "hf_inference" → Hugging Face Serverless Inference Providers. Requires HF credits. |
| "local" → Download + run model weights locally via transformers/diffusers. |
| "mock" → Return a procedurally generated placeholder asset instantly. |
| """ |
|
|
| import os |
|
|
| |
| |
| |
| |
|
|
| PROFILES = { |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| "groq_cloud": { |
| "prompt_expansion": { |
| "backend": "groq", |
| "model": "llama-3.1-8b-instant", |
| }, |
| "image_generation": { |
| "backend": "pollinations", |
| "model": None, |
| }, |
| "depth_estimation": { |
| "backend": "local", |
| "model": "depth-anything/Depth-Anything-V2-Small-hf", |
| }, |
| "audio_generation": { |
| "backend": "auto", |
| "model": "facebook/musicgen-small", |
| }, |
| "video_generation": { |
| "backend": "auto", |
| "model": "ali-vilab/i2vgen-xl", |
| }, |
| }, |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| "gemini_cloud": { |
| "prompt_expansion": { |
| "backend": "gemini", |
| "model": "gemini-2.0-flash", |
| }, |
| "image_generation": { |
| "backend": "gemini", |
| |
| "model": "gemini-2.0-flash-preview-image-generation", |
| }, |
| "depth_estimation": { |
| "backend": "local", |
| "model": "depth-anything/Depth-Anything-V2-Small-hf", |
| }, |
| "audio_generation": { |
| "backend": "auto", |
| "model": "facebook/musicgen-small", |
| }, |
| "video_generation": { |
| "backend": "auto", |
| "model": "ali-vilab/i2vgen-xl", |
| }, |
| }, |
|
|
| |
| |
| |
| |
| |
| |
| |
| "huggingface": { |
| "prompt_expansion": { |
| "backend": "hf_inference", |
| "model": "Qwen/Qwen2.5-72B-Instruct", |
| }, |
| "image_generation": { |
| "backend": "hf_inference", |
| "model": "black-forest-labs/FLUX.1-schnell", |
| }, |
| "depth_estimation": { |
| "backend": "local", |
| "model": "depth-anything/Depth-Anything-V2-Small-hf", |
| }, |
| "audio_generation": { |
| "backend": "auto", |
| "model": "facebook/musicgen-small", |
| }, |
| "video_generation": { |
| "backend": "auto", |
| "model": "ali-vilab/i2vgen-xl", |
| }, |
| }, |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| "local_gpu": { |
| "prompt_expansion": { |
| "backend": "local", |
| "model": "mistralai/Mistral-7B-Instruct-v0.2", |
| }, |
| "image_generation": { |
| "backend": "local", |
| "model": "stable-diffusion-v1-5/stable-diffusion-v1-5", |
| }, |
| "depth_estimation": { |
| "backend": "local", |
| "model": "depth-anything/Depth-Anything-V2-Small-hf", |
| }, |
| "audio_generation": { |
| "backend": "local", |
| "model": "facebook/musicgen-small", |
| }, |
| "video_generation": { |
| "backend": "local", |
| "model": "ali-vilab/i2vgen-xl", |
| }, |
| }, |
|
|
| |
| |
| |
| |
| |
| |
| |
| "mock": { |
| "prompt_expansion": {"backend": "mock", "model": None}, |
| "image_generation": {"backend": "mock", "model": None}, |
| "depth_estimation": {"backend": "mock", "model": None}, |
| "audio_generation": {"backend": "mock", "model": None}, |
| "video_generation": {"backend": "mock", "model": None}, |
| }, |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| ACTIVE_PROFILE_NAME = os.getenv("INFERENCE_PROFILE", "groq_cloud") |
|
|
| |
| if ACTIVE_PROFILE_NAME not in PROFILES: |
| print(f"[Config Warning] Unknown INFERENCE_PROFILE='{ACTIVE_PROFILE_NAME}'. Falling back to 'mock'.") |
| ACTIVE_PROFILE_NAME = "mock" |
|
|
| |
| ACTIVE_PROFILE = PROFILES[ACTIVE_PROFILE_NAME] |
|
|
| print(f"[Config] Active inference profile: '{ACTIVE_PROFILE_NAME}'") |
|
|
|
|
| def get_stage_config(stage_name: str) -> dict: |
| """ |
| WHAT: Returns the backend + model config for a given pipeline stage. |
| WHY: Model wrappers call this to know which backend they should use. |
| HOW: Looks up the stage in the ACTIVE_PROFILE and returns the config dict. |
| """ |
| config = ACTIVE_PROFILE.get(stage_name) |
| if not config: |
| print(f"[Config Warning] Stage '{stage_name}' not found in profile '{ACTIVE_PROFILE_NAME}'. Using mock.") |
| return {"backend": "mock", "model": None} |
| return config |
|
|