-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVATE.py
More file actions
75 lines (61 loc) · 2.16 KB
/
Copy pathVATE.py
File metadata and controls
75 lines (61 loc) · 2.16 KB
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
import os
from typing import Iterable
import pandas as pd
from abc import ABC, abstractmethod
from pathlib import Path
import random
import numpy as np
from collections import defaultdict
from dataset import DatasetFS
from utils import *
class VATEDataset(DatasetFS):
"""
Class describing the dataset VATE.
Filename example: Question_01.mp4
"""
def __init__(self, args: Args, ext: str, verbose=0):
# super class's constructor
super().__init__(args, ext, verbose)
self.info_path = os.path.join(args.DATASET_ARGS["data_path"], "info.txt")
# set class names
if args.DATASET_ARGS["store"]:
# self.shuffle()
self.store_dataset()
if self.args.DATASET_ARGS["shuffle"]:
print("The dataset has been shuffled")
self.shuffle()
else:
if self.args.DATASET_ARGS["shuffle"]:
print("The dataset has been shuffled")
self.shuffle()
# @abstractmethod
def set_classes(self):
emotions = {"01": "neutral", "02": "calm", "03": "happy", "04": "sad", "05": "angry", "06": "fearful", "07": "disgust", "08": "surprised"}
classes = []
actors = []
for fname in self.data_frame["filename"]:
fname = fname.split(".")[-2]
s = fname.split("-")
classes.append(emotions[s[2]])
actors.append(s[6])
# replaces classes in the serie
self.data_frame["class"] = classes
self.classes = classes
# add actors
self.data_frame["actor"] = actors
self.actors = actors
def train_test_split(self) -> list[list]:
"""
Splits the dataset into training and test sets.
Returns:
list[list]: A list containing the indices of the training samples.
"""
# collect data in train lists
X_train_list = []
for i in range(self.size()):
X_train_list.append(i)
# final shuffle
permute = np.random.permutation(len(X_train_list)).tolist()
X_train_list = np.array(X_train_list)[permute].tolist()
# return
return X_train_list