def align_faces(inputDir, outputDir):
os.system("./util/align-dlib.py"+ " " + inputDir + " " + "align outerEyesAndNose"+ " " + outputDir + " " +"--size 96")
def generate_embeddings_files(path, company):
os.system("./batch-represent/main.lua -outDir"+" "+path+" "+"-data ./aligned-images/"+company+"/")
def train_embeddings(company):
os.system("./demos/classifier.py train ./generated-embeddings/"+company+"/")
def predict_face(company, image_path):
conf = subprocess.check_output(["./demos/classifier.py", "infer", "./generated-embeddings/"+company+"/"+"classifier.pkl", image_path])
return conf
def generate_embeddings(request):
try:
data = req_data(request, True)
company = str(data["company"])
file_path = "./aligned-images/"
gen_emb_path = "./generated-embeddings/"+company+"/"
if os.path.exists(gen_emb_path):
shutil.rmtree(gen_emb_path)
file_path = "./aligned-images/" + str(data["company"]) + "/" + "cache.t7"
if os.path.exists(file_path):
os.remove(file_path)
generate_embeddings_files(gen_emb_path, company)
return HttpResponse("Success!", status=200)
except Exception as err:
print(err)
return HttpResponse(err, status=400)
def train_classifier(request):
try:
data = req_data(request, True)
company = str(data["company"])
train_embeddings(company)
return HttpResponse("Success!", status=200)
except Exception as err:
print(err
)
So right after I did this I updated my site which is running in Google Compute Engine. The result was that it was able to align the images, train them, but, it didn't produce a classifier.pkl. And when I tried recognizing the faces, the images did not appear. So my question is that is there any work around to this problem? Thanks!