Spaces:
Running
on
Zero
Running
on
Zero
trying to avoid second load
Browse files
app.py
CHANGED
|
@@ -127,7 +127,6 @@ class ModelManager:
|
|
| 127 |
self.is_loaded = True
|
| 128 |
self.is_loading = False
|
| 129 |
print("Model loaded successfully!")
|
| 130 |
-
return self.model
|
| 131 |
|
| 132 |
except Exception as e:
|
| 133 |
print(f"Error loading model: {e}")
|
|
@@ -179,9 +178,9 @@ def prompt_lm(
|
|
| 179 |
list[str]: List of generated responses for each audio-query pair
|
| 180 |
"""
|
| 181 |
if model_manager.model is None:
|
| 182 |
-
|
| 183 |
|
| 184 |
-
if model is None:
|
| 185 |
if model_manager.is_loading:
|
| 186 |
return "π Loading model for the first query. This takes 20-30 seconds..π·π½ββοΈπ¨πͺ"
|
| 187 |
# while True:
|
|
@@ -196,7 +195,7 @@ def prompt_lm(
|
|
| 196 |
return "Demo mode: Model not loaded. Please check the model configuration."
|
| 197 |
|
| 198 |
with torch.amp.autocast(device_type="cuda", dtype=torch.float16):
|
| 199 |
-
results: list[list[dict]] = model(
|
| 200 |
audios,
|
| 201 |
queries,
|
| 202 |
window_length_seconds=window_length_seconds,
|
|
|
|
| 127 |
self.is_loaded = True
|
| 128 |
self.is_loading = False
|
| 129 |
print("Model loaded successfully!")
|
|
|
|
| 130 |
|
| 131 |
except Exception as e:
|
| 132 |
print(f"Error loading model: {e}")
|
|
|
|
| 178 |
list[str]: List of generated responses for each audio-query pair
|
| 179 |
"""
|
| 180 |
if model_manager.model is None:
|
| 181 |
+
model_manager.load_model()
|
| 182 |
|
| 183 |
+
if model_manager.model is None:
|
| 184 |
if model_manager.is_loading:
|
| 185 |
return "π Loading model for the first query. This takes 20-30 seconds..π·π½ββοΈπ¨πͺ"
|
| 186 |
# while True:
|
|
|
|
| 195 |
return "Demo mode: Model not loaded. Please check the model configuration."
|
| 196 |
|
| 197 |
with torch.amp.autocast(device_type="cuda", dtype=torch.float16):
|
| 198 |
+
results: list[list[dict]] = model_manager.model(
|
| 199 |
audios,
|
| 200 |
queries,
|
| 201 |
window_length_seconds=window_length_seconds,
|