表情识别
目錄
- 一、數據集
- 1.1 ExpW表情數據集
- 1.2 人臉表情數據集-fer2013
- 1.3 FERPlus
- 1.3.1 數據集讀取
- 1.4 數據集預處理
- 1.5 爬蟲爬取表情包(測試集)
- 二、表情識別模型
- 2.1 模型輸入需求
- 三、微博爬取評論
- 深度學習網絡圖畫圖工具
一、數據集
1.1 ExpW表情數據集
備用數據集,爬蟲爬取的,原數據集并沒有將人臉提取出來
數據預處理:
表情識別/情緒識別:ExpW表情數據集
表情識別/情緒識別:ExpW表情數據集
《Deep Facial Expression Recognition:A Survey》論文筆記
1.2 人臉表情數據集-fer2013
由35886張人臉表情圖片組成:
測試:28708張
公共驗證圖:3589
私有驗證圖:3589
48×48的灰度圖像
共7種表情:
0 anger 生氣
1 disgust 厭惡
2 fear 恐懼
3 happy 開心
4 sad 傷心
5 surprised 驚訝
6 normal 中性
處理完了才發現fer2013有了微軟更正標注版本的fer+…(難受)
1.3 FERPlus
FER2013和FERPlus是常用的表情識別訓練集。
https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data
FERPlus可以下載:
https://www.worldlink.com.cn/osdir/ferplus.html
fer2013人臉表情識別案例
Tensorflow讀取fer2013
pytorch人臉表情識別實驗——fer2013
1.3.1 數據集讀取
data = pd.read_csv('../input/fer2013.csv')1.4 數據集預處理
Deep Facial Expression Recognition: A Survey筆記
再開始識別表情之前得先對齊臉
參考代碼文章
也可以直接使用第三方庫 face_recognition
- face_recognition是基于dlib的深度學習人臉識別庫,在LFW上的準確率達到了99.38%
- face_recognition包括人臉檢測、人臉關鍵點檢測、人臉識別等接口
- 人臉檢測:返回的結構是一個list,每個人臉是一個tuple存儲,分別代表框住人臉的矩形中左上角和右下角的坐標(x1,y1,x2,y2)
- 人臉關鍵點檢測:得到人臉特征點list,每個人臉是一個字典,包括nose_bridge、right_eyebrow、right_eye、chine、left_eyebrow、bottom_lip、nose_tip、top_lip、left_eye幾個部分,每個部分包含若干個特征點(x,y),總共有68個特征點。
1.5 爬蟲爬取表情包(測試集)
#test_爬取來自www.doutula.com的表情包 from urllib import request from urllib import parse import urllib import re import sys import os import timepage=1 x=0 totolnum=0 sys.stdin.encodingdef filename(keyword):path=os.path.abspath('.')newpath=path+'\\img\\'+keywordif(os.path.exists(newpath)==False):os.makedirs(path+'\\img\\'+keyword)return newpathdef link(keyword,pagenum):qkeyword=urllib.parse.quote(keyword)page="&page="+str(pagenum)search='search?type=photo&more=1&keyword='url="http://www.doutula.com/"link=url+search+qkeyword+pagereq=request.Request(link)req.add_header('user-agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36')text=request.urlopen(req).read()text=text.decode('utf-8')return textdef content(keyword,pagenum):text=link(keyword,pagenum)pattern1='data-original="(http|https):(/|\w|\.)+(gif|jpg|png)"'match=re.finditer(pattern1,text)return matchkeyword=input("請輸入想要爬取的表情包的名字 ") page=int(input("請輸入爬取頁數 ")) newpath=filename(keyword) if os.path.exists('match.txt')==True:os.remove('match.txt')for pagei in range(1,page+1):match=content(keyword,pagei)f=open('match.txt','a+')f.write('\n')for i in match:f.write(i.group())f.write('\n')totolnum+=1f.close()f=open('match.txt','r+') str=f.read() pattern2='(http|https):(/|\w|\.)+(gif|jpg|png)' src=re.finditer(pattern2,str) for i in src:urllib.request.urlretrieve(i.group(),newpath+'\\'+'%s.jpg' %(x+1))x+=1print('正在爬取%d/%d' %(x,totolnum))time.sleep(0.8) f.close()if totolnum==0:print('對不起,找不到關于%s的表情包,請重新輸入' %keyword) else:print('爬取完成,爬取%d個文件\n保存在%s' %(totolnum,newpath))二、表情識別模型
2.1 模型輸入需求
三、微博爬取評論
python爬蟲之爬取手機微博評論(圖文并排,炒雞詳細!!!)
python爬取微博評論及評論中的圖片
NLP之情感分析:基于python編程(jieba庫)實現中文文本情感分析(得到的是情感評分)
深度學習網絡圖畫圖工具
使用表情生成新的圖片
PyTorch實現"StarGAN:使用單一模型執行多個域的圖像轉換"。
表情識別之scn
認識了一個新的庫:Hugging Face
Hugging face快速入門:是Transformers的庫
總結
- 上一篇: 应用于电力电子变压器的双向DC_DC变换
- 下一篇: 【Matlab代码】基于小波分析的音频信