download ensemble model

This commit is contained in:
Şefik Serangil 2020-07-01 14:19:12 +03:00
parent f5087440fc
commit 9fcd62adcc
2 changed files with 25 additions and 7 deletions

View File

@ -4,6 +4,8 @@ warnings.filterwarnings("ignore")
import time
import os
from os import path
from pathlib import Path
import gdown
import numpy as np
import pandas as pd
from tqdm import tqdm
@ -131,12 +133,21 @@ def verify(img1_path, img2_path=''
#-------------------------------
#find deepface path
deepface_path = DeepFace.__file__
deepface_path = deepface_path.replace("\\", "/").replace("/DeepFace.py", "")
ensemble_model_path = deepface_path+"/models/face-recognition-ensemble-model.txt"
home = str(Path.home())
if os.path.isfile(home+'/.deepface/weights/face-recognition-ensemble-model.txt') != True:
print("face-recognition-ensemble-model.txt will be downloaded...")
url = 'https://raw.githubusercontent.com/serengil/deepface/master/deepface/models/face-recognition-ensemble-model.txt'
output = home+'/.deepface/weights/face-recognition-ensemble-model.txt'
gdown.download(url, output, quiet=False)
ensemble_model_path = home+'/.deepface/weights/face-recognition-ensemble-model.txt'
#print(ensemble_model_path)
#-------------------------------
deepface_ensemble = lgb.Booster(model_file = ensemble_model_path)
prediction = deepface_ensemble.predict(np.expand_dims(np.array(ensemble_features), axis=0))[0]
@ -732,9 +743,16 @@ def find(img_path, db_path
#----------------------------------
#lightgbm model
deepface_path = DeepFace.__file__
deepface_path = deepface_path.replace("\\", "/").replace("/DeepFace.py", "")
ensemble_model_path = deepface_path+"/models/face-recognition-ensemble-model.txt"
home = str(Path.home())
if os.path.isfile(home+'/.deepface/weights/face-recognition-ensemble-model.txt') != True:
print("face-recognition-ensemble-model.txt will be downloaded...")
url = 'https://raw.githubusercontent.com/serengil/deepface/master/deepface/models/face-recognition-ensemble-model.txt'
output = home+'/.deepface/weights/face-recognition-ensemble-model.txt'
gdown.download(url, output, quiet=False)
ensemble_model_path = home+'/.deepface/weights/face-recognition-ensemble-model.txt'
deepface_ensemble = lgb.Booster(model_file = ensemble_model_path)
y = deepface_ensemble.predict(x)

View File

@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="deepface",
version="0.0.32",
version="0.0.33",
author="Sefik Ilkin Serengil",
author_email="serengil@gmail.com",
description="A Lightweight Face Recognition and Facial Attribute Analysis Framework (Age, Gender, Emotion, Race) for Python",