File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 19
19
20
20
from src .constants import ENV
21
21
from src .exceptions import NoFaceFoundError
22
- from src .services .facescan .plugins import base , managers
22
+ from src .services .facescan .plugins import managers
23
23
from src .services .facescan .scanner .facescanners import scanner
24
24
from src .services .flask_ .constants import ARG
25
25
from src .services .flask_ .needs_attached_file import needs_attached_file
26
26
from src .services .imgtools .read_img import read_img
27
27
from src .services .utils .pyutils import Constants
28
+ from src .services .imgtools .test .files import IMG_DIR
28
29
import base64
29
30
30
31
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
+
31
42
def endpoints (app ):
32
43
@app .route ('/status' )
33
44
def status_get ():
Original file line number Diff line number Diff line change 19
19
20
20
from src import constants
21
21
from src ._docs import add_docs
22
- from src ._endpoints import endpoints
22
+ from src ._endpoints import endpoints , init_model
23
23
from src .constants import ENV
24
24
from src .docs import DOCS_DIR
25
25
from src .init_runtime import init_runtime
@@ -38,6 +38,7 @@ def init_app_runtime():
38
38
39
39
def create_app (add_endpoints_fun : Union [Callable , None ] = None , do_add_docs : bool = False ):
40
40
app = Flask ('embedding-calculator' )
41
+ app .before_first_request_funcs .append (init_model )
41
42
app .url_map .strict_slashes = False
42
43
add_error_handling (app )
43
44
app .after_request (log_http_response )
You can’t perform that action at this time.
0 commit comments