数据与代码链接:
https://download.csdn.net/download/fzf1996/83066661
环境搭建
win10,pycham2020.2
python版本:Python 3.7.9
安装包:
C:\Users\Administrator>pip list
Package Version
---------------------- ----------
absl-py 0.11.0
argon2-cffi 20.1.0
astor 0.8.1
astunparse 1.6.3
async-generator 1.10
attrs 20.3.0
backcall 0.2.0
bidict 0.21.2
biosppy 0.6.1
bleach 3.2.1
cachetools 4.2.0
certifi 2020.12.5
cffi 1.14.4
chardet 4.0.0
chart-studio 1.1.0
colorama 0.4.4
cycler 0.10.0
decorator 4.4.2
defusedxml 0.6.0
entrypoints 0.3
flatbuffers 1.12
gast 0.2.2
google-auth 1.24.0
google-auth-oauthlib 0.4.2
google-pasta 0.2.0
grpcio 1.32.0
h5py 2.10.0
idna 2.10
importlib-metadata 3.3.0
ipykernel 5.4.2
ipython 7.19.0
ipython-genutils 0.2.0
ipywidgets 7.6.2
jedi 0.18.0
Jinja2 2.11.2
joblib 1.0.0
jsonschema 3.2.0
jupyter 1.0.0
jupyter-client 6.1.7
jupyter-console 6.2.0
jupyter-core 4.7.0
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.0.0
Keras 2.3.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.2
kiwisolver 1.3.1
Markdown 3.3.3
MarkupSafe 1.1.1
matplotlib 3.3.3
mistune 0.8.4
mne 0.22.0
nbclient 0.5.1
nbconvert 6.0.7
nbformat 5.0.8
nest-asyncio 1.4.3
notebook 6.1.6
numpy 1.19.4+mkl
oauthlib 3.1.0
opencv-python 4.4.0.46
opt-einsum 3.3.0
packaging 20.8
pandas 1.2.0
pandocfilters 1.4.3
parso 0.8.1
pickleshare 0.7.5
Pillow 8.0.1
pip 20.3.3
plotly 4.14.1
prometheus-client 0.9.0
prompt-toolkit 3.0.8
protobuf 3.14.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.20
Pygments 2.7.3
pyparsing 2.4.7
pyriemann 0.2.6
pyrsistent 0.17.3
python-dateutil 2.8.1
pytz 2020.5
PyWavelets 1.1.1
pywin32 300
pywinpty 0.5.7
pywt 1.0.6
PyYAML 5.3.1
pyzmq 20.0.0
qtconsole 5.0.1
QtPy 1.9.0
requests 2.25.1
requests-oauthlib 1.3.0
retrying 1.3.3
rsa 4.6
scikit-learn 0.21.3
scipy 1.6.0
seaborn 0.11.1
Send2Trash 1.5.0
setuptools 51.1.1
shortuuid 1.0.1
six 1.15.0
tensorboard 2.0.2
tensorboard-plugin-wit 1.7.0
tensorflow 2.0.0
tensorflow-estimator 2.0.1
termcolor 1.1.0
terminado 0.9.1
testpath 0.4.4
threadpoolctl 2.1.0
tornado 6.1
traitlets 5.0.5
typing-extensions 3.7.4.3
urllib3 1.26.2
wcwidth 0.2.5
webencodings 0.5.1
Werkzeug 1.0.1
wheel 0.36.2
widgetsnbextension 3.5.1
wrapt 1.12.1
zipp 3.4.0
数据集描述
DEAP: A Dataset for Emotion Analysis using Physiological and Audiovisual Signals
The DEAP dataset consists of two parts:
- The ratings from an online self-assessment where 120 one-minute extracts of music videos were each rated by 14-16 volunteers based on arousal, valence and dominance.
- The participant ratings, physiological recordings and face video of an experiment where 32 volunteers watched a subset of 40 of the above music videos. EEG and physiological signals were recorded and each participant also rated the videos as above. For 22 participants frontal face video was also recorded
如果用自己的实验数据不准确,而且公信力不够,所以采用公开数据集。deap数据集很大,申请时间很长很难。加上代码算法的实现难度也大,做出来也是不简单。
特征提取
def get_feature(self,all_channel_data):
(delta,theta,alpha,beta,gamma) = self.get_frequency(all_channel_data)
delta_std = np.std(delta,axis=1)
theta_std = np.std(theta,axis=1)
alpha_std = np.std(alpha,axis=1)
beta_std = np.std(beta,axis=1)
gamma_std = np.std(gamma,axis=1)
feature = np.array([delta_std,theta_std,alpha_std,beta_std,gamma_std])
feature = feature.T
feature = feature.ravel()
return feature
根据特征进行分类
determine_emotion_class(feature)
分类结果显示
def send_result_to_window(self,emotion_class):
"""
Send emotion predict to web app.
Input: Class of emotion between 1 to 5 according to Russel's Circumplex Model.
Output: Send emotion prediction to web window.
"""
i1=cv2.imread('emoji/1.png')
i2=cv2.imread('emoji/2.png')
i3=cv2.imread('emoji/3.png')
i4=cv2.imread('emoji/4.png')
i5=cv2.imread('emoji/5.png')
if emotion_class==1:
cv2.imshow('image',i1)
elif emotion_class==2:
cv2.imshow('image',i2)
elif emotion_class==3:
cv2.imshow('image',i3)
elif emotion_class==4:
cv2.imshow('image',i4)
else:
cv2.imshow('image',i5)
cv2.waitKey(0)
cv2.destroyAllWindows()
实现结果:
S04的结果
S02的结果