-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraining.py
39 lines (34 loc) · 1.06 KB
/
training.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import face_recognition
import cv2
import re
import numpy as np
import requests
from os import listdir
from os.path import isfile, join
def find_between(s, first, last):
try:
start = s.index(first) + len(first)
end = s.index(last, start)
return s[start:end]
except ValueError:
return ""
individuals = 'E:\\khk\\volumeF\\soft1\\WinPython\\settings\\.spyder-py3\\facedetection\\individ\\'
onlyfiles = [f for f in listdir(individuals) if isfile(join(individuals, f))]
data = []
stringall = ''
loop = 0
for individual in onlyfiles:
print(loop)
loop = loop + 1
loadiamge = face_recognition.load_image_file(individuals + individual)
face_encoding = face_recognition.face_encodings(loadiamge)[0]
file = open("encodings.txt", "a")
stringall = ''
for x in face_encoding:
stringall = stringall + str(x) + ",\n"
file.write(stringall)
file.close()
file = open("encodingnames.txt", "a")
file.write(individual + ",")
file.close()
data.append(face_encoding)