Spaces:
Sleeping
Sleeping
az30667176-sudo commited on
Commit ·
5347699
1
Parent(s): 5234366
fix: preload model at module level; simplify launch pattern
Browse files
app.py
CHANGED
|
@@ -193,10 +193,13 @@ with gr.Blocks(title="Kronos Filter API") as demo:
|
|
| 193 |
)
|
| 194 |
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
if __name__ == "__main__":
|
| 197 |
-
|
| 198 |
-
try:
|
| 199 |
-
get_predictor()
|
| 200 |
-
except Exception as e:
|
| 201 |
-
logger.warning(f"Failed to preload model: {e}")
|
| 202 |
-
demo.queue(default_concurrency_limit=1).launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 193 |
)
|
| 194 |
|
| 195 |
|
| 196 |
+
# Pre-load model at module import (first request won't have cold-start lag)
|
| 197 |
+
try:
|
| 198 |
+
get_predictor()
|
| 199 |
+
except Exception as e:
|
| 200 |
+
logger.warning(f"Failed to preload model: {e}")
|
| 201 |
+
|
| 202 |
+
demo.queue(default_concurrency_limit=1)
|
| 203 |
+
|
| 204 |
if __name__ == "__main__":
|
| 205 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|