From 92408a54d21534d4708e6505f0cbc0335578a47d Mon Sep 17 00:00:00 2001 From: Rif'at Ahdi R <10791791+atrifat@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:33:00 +0800 Subject: [PATCH] feat: Warming up language detection model before starting API server --- app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.py b/app.py index 2c5c061..07b254b 100644 --- a/app.py +++ b/app.py @@ -49,6 +49,10 @@ if ENABLE_API_TOKEN and API_TOKEN == "": raise Exception("API_TOKEN is required if ENABLE_API_TOKEN is enabled") +# Ensure model warmed-up for fast_langdetect before starting API server +if LANGUAGE_DETECTION_MODEL == "fast_langdetect": + detect_multilingual("", low_memory=LOW_MEMORY_MODE) + app = Flask(__name__) cache_config = {