Skip to content
Open
6 changes: 6 additions & 0 deletions dev/docker-compose-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ services:
- ML_PORT=3000
- UWSGI_PROCESSES=${uwsgi_processes:-1}
- UWSGI_THREADS=${uwsgi_threads:-1}
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
interval: 10s
retries: 0
start_period: 0s
timeout: 1s
6 changes: 6 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,9 @@ services:
- ML_PORT=3000
- UWSGI_PROCESSES=${uwsgi_processes:-2}
- UWSGI_THREADS=${uwsgi_threads:-1}
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
interval: 10s
retries: 0
start_period: 0s
timeout: 1s
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ services:
- IMG_LENGTH_LIMIT=${max_detect_size}
- UWSGI_PROCESSES=${uwsgi_processes:-2}
- UWSGI_THREADS=${uwsgi_threads:-1}
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
interval: 10s
retries: 0
start_period: 0s
timeout: 1s
24 changes: 22 additions & 2 deletions embedding-calculator/src/_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing
# permissions and limitations under the License.

from typing import List, Optional

from flask import request
Expand All @@ -19,12 +20,13 @@

from src.constants import ENV
from src.exceptions import NoFaceFoundError
from src.services.facescan.plugins import base, managers
from src.services.facescan.plugins import managers
from src.services.facescan.scanner.facescanners import scanner
from src.services.flask_.constants import ARG
from src.services.flask_.needs_attached_file import needs_attached_file
from src.services.imgtools.read_img import read_img
from src.services.utils.pyutils import Constants
from src.services.imgtools.test.files import IMG_DIR
import base64
from src.constants import SKIPPED_PLUGINS

Expand All @@ -41,8 +43,26 @@ def face_detection_skip_check(face_plugins):
else:
return face_plugins


def endpoints(app):
@app.before_first_request
def init_model() -> None:
detector = managers.plugin_manager.detector
face_plugins = managers.plugin_manager.face_plugins
face_plugins = face_detection_skip_check(face_plugins)
detector(
img=read_img(str(IMG_DIR / 'einstein.jpeg')),
det_prob_threshold=_get_det_prob_threshold(),
face_plugins=face_plugins
)
print("Starting to load ML models")
return None

@app.route('/healthcheck')
def healthcheck():
return jsonify(
status='OK'
)

@app.route('/status')
def status_get():
available_plugins = {p.slug: str(p)
Expand Down