dreamland / core /model_manager.py
panda-lsy
fix: move @spaces.GPU to app.py for ZeroGPU detection
f4a1f39
Raw
History Blame Contribute Delete
915 Bytes
"""Model manager — delegates to gpu_generate."""
import logging
from typing import Optional
import config
logger = logging.getLogger(__name__)
class ModelManager:
_instance: Optional["ModelManager"] = None
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance._initialized = False
return cls._instance
def __init__(self):
if self._initialized:
return
self._initialized = True
@property
def generate_fn(self) -> callable:
"""Get the generate function — prefers GPU version from app.py."""
import core.gpu_generate as gpg
# app.py registers the @spaces.GPU version on the module
return getattr(gpg, 'gpu_generate', gpg.gpu_generate)
def parse_image(self, image_path: str, prompt: str = None) -> str:
return "[Vision not available]"