-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysis_of_training_data.py
73 lines (61 loc) · 1.76 KB
/
analysis_of_training_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 15 11:15:43 2021
@author: safayet_khan
"""
# Importing necessary libraries
import glob
import os
import numpy as np
import matplotlib.pyplot as plt
# Necessary constant values are being fixed
MAIN_DIR = "C:/Users/safayet_khan/Desktop/emotion_recognition/processed_data"
CLASSES = [
"anger",
"contempt",
"disgust",
"fear",
"happiness",
"neutral",
"sadness",
"surprise",
]
DATA_DIR = os.path.join(MAIN_DIR, "emotion_data")
PROCESSED_DATA_DIR = os.path.join(MAIN_DIR, "emotion_data_flow/train")
# Number of Images in each training folder
number_of_images = np.empty(len(CLASSES), dtype=np.uint16)
number_of_processed_images = np.empty(len(CLASSES), dtype=np.uint16)
for index, folder_name in enumerate(CLASSES):
number_of_images[index] = len(
glob.glob(os.path.join(DATA_DIR, folder_name, "*.png"))
)
number_of_processed_images[index] = len(
glob.glob(os.path.join(PROCESSED_DATA_DIR, folder_name, "*.png"))
)
# Necessary values for plotting graph
GRAPH_WIDTH = 0.40
NUMBER_OF_CLASSES = len(CLASSES)
X_AXIS = np.arange(NUMBER_OF_CLASSES)
plt.bar(
X_AXIS,
number_of_images,
color="b",
width=GRAPH_WIDTH,
edgecolor="black",
label="Images per class of raw data",
)
plt.bar(
X_AXIS + GRAPH_WIDTH,
number_of_processed_images,
color="g",
width=GRAPH_WIDTH,
edgecolor="black",
label="Training images per class after oversampling",
)
plt.xlabel("Name of Classes")
plt.ylabel("Number of Images")
plt.title("Analysis of Training Data")
plt.grid(linestyle=(0, (1, 10))) # (0, (1, 10)) -> 'loosely dotted'
plt.xticks(X_AXIS + GRAPH_WIDTH / 2, CLASSES)
plt.legend()
plt.show()