File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1919
2020from src .constants import ENV
2121from src .exceptions import NoFaceFoundError
22- from src .services .facescan .plugins import base , managers
22+ from src .services .facescan .plugins import managers
2323from src .services .facescan .scanner .facescanners import scanner
2424from src .services .flask_ .constants import ARG
2525from src .services .flask_ .needs_attached_file import needs_attached_file
2626from src .services .imgtools .read_img import read_img
2727from src .services .utils .pyutils import Constants
28+ from src .services .imgtools .test .files import IMG_DIR
2829import base64
2930
3031
32+ def init_model () -> None :
33+ detector = managers .plugin_manager .detector
34+ face_plugins = managers .plugin_manager .face_plugins
35+ detector (
36+ img = read_img (str (IMG_DIR / 'einstein.jpeg' )),
37+ det_prob_threshold = _get_det_prob_threshold (),
38+ face_plugins = face_plugins
39+ )
40+ return None
41+
3142def endpoints (app ):
3243 @app .route ('/status' )
3344 def status_get ():
Original file line number Diff line number Diff line change 1919
2020from src import constants
2121from src ._docs import add_docs
22- from src ._endpoints import endpoints
22+ from src ._endpoints import endpoints , init_model
2323from src .constants import ENV
2424from src .docs import DOCS_DIR
2525from src .init_runtime import init_runtime
@@ -38,6 +38,7 @@ def init_app_runtime():
3838
3939def create_app (add_endpoints_fun : Union [Callable , None ] = None , do_add_docs : bool = False ):
4040 app = Flask ('embedding-calculator' )
41+ app .before_first_request_funcs .append (init_model )
4142 app .url_map .strict_slashes = False
4243 add_error_handling (app )
4344 app .after_request (log_http_response )
You can’t perform that action at this time.
0 commit comments