forked from Sounmay/FacialRecProj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_work.py
More file actions
36 lines (28 loc) · 809 Bytes
/
project_work.py
File metadata and controls
36 lines (28 loc) · 809 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 15 17:43:40 2020
@author: Sounmay Mishra
"""
import os
import cv2
import numpy as np
import pickle
def preprocessing(image):
image = cv2.resize(image,(200,200))
image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
return image
data_dir = os.path.join(os.getcwd(),'clean_data')
im_dir = os.path.join(os.getcwd(),'images')
data = []
label = []
for i in os.listdir(im_dir):
image = cv2.imread(os.path.join(im_dir,i))
image = preprocessing(image)
data.append(image)
label.append(i.split('_')[0])
data = np.array(data)
label = np.array(label)
with open(os.path.join(data_dir,'images.p'),'wb') as f:
pickle.dump(data,f)
with open(os.path.join(data_dir,'label.p'),'wb') as f:
pickle.dump(data,f)