-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategorize_cs_3.py
80 lines (67 loc) · 2.89 KB
/
categorize_cs_3.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pandas as pd
'''
surprise: surprise
positive: happiness
negative: CASME II(disgust fear sadness repression) SAMM(disgust fear sadness repression anger)
'''
# CASME II
root_video_dir = '../CASME2/Cropped-updated/Cropped/'
surprise_class = ['surprise']
positive_class = ['happiness']
negative_class = ['disgust', 'fear', 'sadness', 'repression']
categorize_sh = open('categorize_casme_3.sh', 'w')
label_file = open('data_label.txt', 'w')
df = pd.read_excel('../CASME2/CASME2-coding-20190701.xlsx', sheet_name='Sheet1')
video_data = df.iloc[:, [0, 1, 3, 4, 5, 7, 8]].values
for i in range(len(video_data)):
video_subject = str(video_data[i][0]).zfill(2)
video_dir = video_data[i][1]
video_class = video_data[i][-1]
video_onset = str(video_data[i][2])
video_apex = str(video_data[i][3])
video_offset = str(video_data[i][4])
video_AU = str(video_data[i][-2])
video_casme2_class = ''
if video_class in surprise_class:
video_casme2_class = 'surprise'
elif video_class in positive_class:
video_casme2_class = 'positive'
elif video_class in negative_class:
video_casme2_class = 'negative'
else:
# video_casme2_class = 'others'
continue
categorize_sh.writelines('cp -r {} {}\n'.format(root_video_dir + 'sub' + video_subject + '/' + video_dir, './data_3/' + video_casme2_class))
label_file.writelines('{}\t{}\t{}\t{}\t{}\n'.
format('data_3/' + video_casme2_class + '/' + video_dir,
video_onset, video_apex, video_offset, video_AU))
# SAMM
root_video_dir = '../SAMM_cropped/'
surprise_class = ['Surprise']
positive_class = ['Happiness']
negative_class = ['Disgust', 'Fear', 'Sadness', 'Repression', 'Anger']
categorize_sh = open('categorize_samm_3.sh', 'w')
label_file = open('data_label.txt', 'a')
df = pd.read_excel('../SAMM.xlsx', sheet_name='MICRO_ONLY')
video_data = df.iloc[:, [1, 3, 4, 5, 8, 9]].values
for i in range(len(video_data)):
video_dir = video_data[i][0]
video_class = video_data[i][-1]
video_onset = str(video_data[i][1])
video_apex = str(video_data[i][2])
video_offset = str(video_data[i][3])
video_AU = str(video_data[i][-2])
video_samm_class = ''
if video_class in surprise_class:
video_samm_class = 'surprise'
elif video_class in positive_class:
video_samm_class = 'positive'
elif video_class in negative_class:
video_samm_class = 'negative'
else:
# video_samm_class = 'others'
continue
categorize_sh.writelines('cp -r {} {}\n'.format(root_video_dir + video_dir, './data_3/' + video_samm_class))
label_file.writelines('{}\t{}\t{}\t{}\t{}\n'.
format('data_3/' + video_samm_class + '/' + video_dir,
video_onset, video_apex, video_offset, video_AU))