Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,13 +37,14 @@ global_data = {
|
|
37 |
class ModelManager:
|
38 |
def __init__(self):
|
39 |
self.models = {}
|
40 |
-
self.
|
41 |
-
|
42 |
-
def
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
future
|
|
|
47 |
|
48 |
def _load_model(self, model_config):
|
49 |
model_name = model_config['name']
|
|
|
37 |
class ModelManager:
|
38 |
def __init__(self):
|
39 |
self.models = {}
|
40 |
+
self.load_models_once()
|
41 |
+
|
42 |
+
def load_models_once(self):
|
43 |
+
if not self.models: # Load models only once
|
44 |
+
with ThreadPoolExecutor(max_workers=len(global_data['model_configs'])) as executor:
|
45 |
+
futures = [executor.submit(self._load_model, config) for config in tqdm(global_data['model_configs'], desc="Loading models")]
|
46 |
+
for future in tqdm(as_completed(futures), total=len(global_data['model_configs']), desc="Loading models complete"):
|
47 |
+
future.result()
|
48 |
|
49 |
def _load_model(self, model_config):
|
50 |
model_name = model_config['name']
|