File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ service : {
4646 "clear_face_recognition_model_bytes": () -> ();
4747 "append_face_detection_model_bytes": (bytes: blob) -> ();
4848 "append_face_recognition_model_bytes": (bytes: blob) -> ();
49- "setup_models": () -> ();
49+ "setup_models": () -> (variant { Ok: null; Err: text } );
5050
5151 // These endpoints are used only for testing and benchmarking.
5252 "run_detection": () -> (Detection) query;
Original file line number Diff line number Diff line change @@ -130,6 +130,15 @@ fn models_ready() -> bool {
130130/// this function loads them into in-memory models.
131131#[ ic_cdk:: update]
132132fn setup_models ( ) -> Result < ( ) , String > {
133+ if std:: fs:: metadata ( FACE_DETECTION_FILE ) . is_err ( )
134+ || std:: fs:: metadata ( FACE_RECOGNITION_FILE ) . is_err ( )
135+ {
136+ return Err (
137+ "Model files not found — upload them first using append_face_detection_model_bytes \
138+ and append_face_recognition_model_bytes"
139+ . to_string ( ) ,
140+ ) ;
141+ }
133142 setup (
134143 storage:: bytes ( FACE_DETECTION_FILE ) ,
135144 storage:: bytes ( FACE_RECOGNITION_FILE ) ,
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ if [ ! -f "face-recognition.onnx" ]; then
2525 echo " Face recognition model not found — generating with $PYTHON (this may take a few minutes)..."
2626 " $PYTHON " -m pip install --quiet --prefer-binary facenet-pytorch torch onnx certifi
2727 " $PYTHON " << 'PYEOF '
28- import os, ssl, certifi
28+ import os, certifi
2929# Python from python.org on macOS doesn't ship with root certificates;
30- # point urllib at the certifi bundle so pretrained weights can be downloaded .
30+ # point urllib and requests at the certifi bundle so pretrained weights download .
3131os.environ['SSL_CERT_FILE'] = certifi.where()
32- ssl.create_default_context = lambda *a, **kw: ssl.create_default_context(cafile= certifi.where() )
32+ os.environ['REQUESTS_CA_BUNDLE'] = certifi.where()
3333import torch
3434import facenet_pytorch
3535resnet = facenet_pytorch.InceptionResnetV1(pretrained='vggface2').eval()
You can’t perform that action at this time.
0 commit comments