Spaces:
Running
on
T4
Running
on
T4
File size: 857 Bytes
be59b6e bb4f59a be59b6e bb4f59a be59b6e 9e9d8e8 be59b6e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from .colpali import load_model
class ModelManager:
_instance = None
model = None
processor = None
use_dummy_model = False
@staticmethod
def get_instance():
if ModelManager._instance is None:
ModelManager._instance = ModelManager()
if not ModelManager.use_dummy_model:
ModelManager._instance.initialize_model_and_processor()
return ModelManager._instance
def initialize_model_and_processor(self):
if self.model is None or self.processor is None: # Ensure no reinitialization
self.model, self.processor, self.device = load_model()
if self.model is None or self.processor is None:
print("Failed to initialize model or processor at startup")
else:
print("Model and processor loaded at startup")
|