Closed ghost closed 1 year ago
How can I save and load weight of model, so that I can use it in my code. Every time I run code in terminal, it takes around 10-40+ second to give the result. Please help, Thanks.
code:
def face_detect_recog (trained_image_path,input_img_path): models = ["VGG-Face", "Facenet", " Facenet512", "OpenFace", "DeepFace", "DeepID", "Dlib", "ArcFace","SFace"] detector = ["opencv", "retinaface", "mtcnn", "ssd", "dlib", "mediapipe"] metric = ["cosine", "euclidean", "euclidean_l2"] result = DeepFace.verify(trained_image_path, input_img_path, model_name = models[4], detector_backend =detector[3],distance_metric="cosine", align=True ) if result["verified"] == True: return (1,"Face is verified.",result)
else: return (0,"Face is not verified.")
model is already saved into ~/.deepface/weights. time taken process is to load it.
if you use jupyter notebook, this will not take time except first call because it would be stored in the memory once it is called.
How can I save and load weight of model, so that I can use it in my code. Every time I run code in terminal, it takes around 10-40+ second to give the result. Please help, Thanks.
code:
def face_detect_recog (trained_image_path,input_img_path): models = ["VGG-Face", "Facenet", " Facenet512", "OpenFace", "DeepFace", "DeepID", "Dlib", "ArcFace","SFace"] detector = ["opencv", "retinaface", "mtcnn", "ssd", "dlib", "mediapipe"] metric = ["cosine", "euclidean", "euclidean_l2"] result = DeepFace.verify(trained_image_path, input_img_path, model_name = models[4], detector_backend =detector[3],distance_metric="cosine", align=True ) if result["verified"] == True: return (1,"Face is verified.",result)