Beispiel #1
0
def train_dataframe(company_name):
    
    print("Loading Started...")
    known_faces = get_images_with_tag(company_name)
    all_ids = []
    all_locations = []
    fr = FaceRecognition()
    try:
        for name, known_file in known_faces:
           
            all_ids.append(name)
            all_locations.append(known_file)
            print("Loaded: " + name)
            
    except:
        print("Error for " + known_file + " tag: " + name)



    df = pd.DataFrame(list(zip(all_ids, all_locations)), columns =['person', 'path']) 
    print("Fitting started")
    fr.fit_from_dataframe(df)
    fr.save('/var/www/attendancekeeper_' + company_name + '/detector/knn.pkl')
    print("Fitting done")
Beispiel #2
0
import os

from face_recognition import FaceRecognition
from face_detection import get_detected_face

if __name__ == "__main__":
    model_name = "face_recognition.h5"
    image_path = 'ronaldo.jpg'
    face_recognition = FaceRecognition()
    face_recognition.train()
    face_recognition.save(model_name)
# model = FaceRecognition.load_saved_model(os.path.join("model", model_name))
# f = FaceRecognition.model_predict(image_path, os.path.join("model", model_name),
#os.path.join("model", "face_recognition_class_names.npy"))
#print(f"This is {f}")