-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.py
49 lines (40 loc) · 1.28 KB
/
data.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
40
41
42
43
44
45
46
47
48
49
# from PIL import Image
from cv2 import imread
import numpy as np
from pickle import dump
data = []
# lbl = [dad, mom, me]
###############################################################################
# THIS IS TO BE USED AFTER YOU HAVE EXTRACTED FACES FROM preprocess_script.py #
###############################################################################
# EXAMPLE OF WHAT IS TO BE REPLACED BY "use path to your data": "E:/Datasets!!/family_pics/dad/dad"
# FACE 1
for i in range(330):
try:
img = imread("use path to your data"+str(i)+".jpg")
img = img/255.0 # normalization
print("face imported.")
data.append([img, [1, 0, 0]]) # one-hot encoding : [probability of dad, probability of mom, probability of me]
except:
print("image not a face.")
# FACE 2
for i in range(313):
try:
img = imread("use path to your data"+str(i)+".jpg")
img = img/255.0
print("face imported.")
data.append([img, [0, 1, 0]])
except:
print("image not a face.")
# FACE 3
for i in range(290):
try:
img = imread("use path to your data"+str(i)+".jpg")
img = img/255.0
print("face imported.")
data.append([img, [0, 0, 1]])
except:
print("image not a face.")
# print(data, end='\n\n\n\n')
# print(data[0])
dump(data, open("data.pkl", "wb"))