purva98
/
Facial-Emotion-Detection-Using-Convolutional-Neural-Networks-and-Representational-Autoencoder-Units
Public
forked from PrudhviRaj12/Facial-Emotion-Detection-Using-Convolutional-Neural-Networks-and-Representational-Autoencoder-Units
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_test_splitter.py
35 lines (26 loc) · 737 Bytes
/
train_test_splitter.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
import os
from sklearn.model_selection import train_test_split
import numpy as np
"""
Splits files for autoencoder modules
"""
files = os.listdir('resized_JAFFE_data_64_by_64/')
train_data, test_data = train_test_split(files, test_size = 0.25, \
random_state = 123)
def counter(tag, files):
count = 0
for f in files:
if tag in f:
count +=1
return count
tag_list = ['AN', 'SA', 'SU', 'HA', 'DI', 'FE', 'NE']
for t in tag_list:
print t, counter(t, train_data), counter(t, test_data)
train_file = open('train_files.txt', 'w')
for t in train_data:
train_file.write(t + '\n')
train_file.close()
test_file = open('test_files.txt', 'w')
for t in test_data:
test_file.write(t + '\n')
test_file.close()