# Emojify
Turn your facial expression into an emoji.
## Note
This project is still under development. Expect errors in recognition of emoji or other errors.
## What I did here
1. Decided what emojis to use.
2. Stored 250 faces for each facial expression in a special way. The special way is that I took only the eyebrows, eyes, nose and mouth of the face. Rest of the face is removed. (Only my face was used)
3. Trained a CNN on these images.
4. As of today there are 11 facial expressions. (Discussed later).
## Outcome
Watch it <a href="https://youtu.be/izUO2rl0Ur8">here</a>.
## Requirements
0. Python 3.x
1. <a href="https://tensorflow.org">Tensorflow 1.5</a>
2. <a href="https://keras.io">Keras</a>
3. OpenCV 3.4
4. h5py
5. A good grasp over the above 4 topics along with neural networks. Refer to the internet if you have problems with those. I myself am just a begineer in those.
6. dlib
7. A good CPU (preferably with a GPU).
8. Patience.... A lot of it.
9. Tensorboard (for visualizing training)
## Facial expressions used
0 - Neutral<br>
1 - Smile/Happy<br>
2 - Sad<br>
3 - Wink<br>
4 - Kiss<br>
5 - Surprised<br>
6 - Angry<br>
7 - Monkey face<br>
8 - Wink with tongue out<br>
9 - Scared/Terrified<br>
10 - Disgusted<br>
## How to use this repo
This project is done by me and me only. No one else helped me. The model is trained with my face only. So the model might not detect your expressions correctly. Here is what you can do. If you are a newbie to neural networks or machine learning please learn them. This guide contains a lot of technical stuff which you might find hard to understand.
### Create your facial expression dataset
1. Start this file
python create_dataset_webcam.py
2. It will ask for label i.e. facial expression id (more about it later), number of pictures you want to take, and starting image number. You can take as many pictures for each expression as you want but make sure you do it using different lighting conditions, facial poisitions etc. Also make sure you take same number of images for each gesture or else you might introduce a bias. I usually keep it to 250.
3. For the starting image number, make sure you check the images in the dataset/ folder. If the file name of the last file is 249.jpg then you should enter 250 i.e. (last image number + 1)
4. The images will be stored in the new_dataset/ folder.
### Retraining with the new_dataset (HARDER way)
You will see why this method is a bit hard.
#### Load the images of the new_dataset/
1. Start the load_images.py file
python load_images.py
2. Here you will be asked for which dataset folder to use. Enter 'new_dataset/'
3. The images will be stored as pickle file.
4. You will get 6 pickle files viz train_images, train_labels, test_images, test_labels, val_images, and val_labels
#### Retrain the model
1. Start the retrain_cnn_keras.py file.
python retrain_cnn_keras.py
2. Here you will be asked for the trained model file name, new model file name, learning rate, epochs, and batch number.
3. For the trained model file name enter cnn_model_keras.h5
4. For the new model file name you can enter anything. A warning though, if you keep it blank or enter cnn_model_keras.h5, it will replace the original model when training if the validation accuracy increases from the previous step.
5. What I usually do is I enter cnn_model_keras1.h5 or something like that so that I do not mess it up.
6. For the rest of the hyper parameters, they will depend on how large the new_dataset/ is.
7. If the number of images for each expression is >= 250, I usually keep the default learning rate, 10-20 epochs and a batch size of 100.
8. After the training you will see the accuracy of the model.
#### Check the model's accuracy against the dataset/ folder
1. Start the load_images.py file
python load_images.py
2. Here you will be asked for which dataset folder to use. Enter 'dataset/'
3. Start the compute_accuracy.py file
python compute_accuracy.py
4. You will be asked to enter the model name. Enter the new model name. Usually in my case it is cnn_model_keras1.h5.
5. If the accuracy is small i.e the CNN error is greater than 4-5% try retraining the model again. That is, do the 2nd step 'Retrain the model'. Only now you need to use cnn_model_keras1.h5 as the model file name and you can keep the new model file name as blank or anything you want.
6. <b>The lower accuracy happens perhaps due to the incorrect settings of the hyperparameters. Please let me know if I am doing it wrong. Need some expert advice here.</b>
### Training the model from the beginning (EASIER way)
1. After you have stored your images in the new_dataset/ folder, move the contents of the folder to the dataset folder.
2. Start the train_cnn_keras.py file
python train_cnn_keras.py
### Start emojify
1. If you are satisfied with the accuracy of the model then you can start the emoji.py file.
python emojify.py
## How to contribute
If you want to contribute to the dataset then please make a pull request. I will be more than happy to merge the present dataset with your dataset. Just make sure you have moved the contents of the new_dataset/ folder to the dataset/ folder before making a pull request.<br>
If you can optimize the code then feel free to inform me.
## How to cite
Saha, D.. (2018, May 9). emojify (Version 1). figshare. https://doi.org/10.6084/m9.figshare.6241934.v1. Turn your facial expression into an emoji
没有合适的资源?快使用搜索试试~ 我知道了~
Python-Emojify将你的面部表情变成emoji表情符号
共5540个文件
jpg:5501个
png:12个
py:11个
需积分: 39 14 下载量 17 浏览量
2019-08-11
04:15:32
上传
评论
收藏 111.18MB ZIP 举报
温馨提示
Emojify - 将你的面部表情变成emoji表情符号
资源推荐
资源详情
资源评论
收起资源包目录
Python-Emojify将你的面部表情变成emoji表情符号 (5540个子文件)
shape_predictor_68_face_landmarks.dat 95.08MB
events.out.tfevents.1525890712.DESKTOP-AA2AV04 731KB
events.out.tfevents.1525814281.DESKTOP-AA2AV04 731KB
events.out.tfevents.1525891130.DESKTOP-AA2AV04 730KB
events.out.tfevents.1525809760.DESKTOP-AA2AV04 441KB
events.out.tfevents.1525811691.DESKTOP-AA2AV04 440KB
events.out.tfevents.1525882859.DESKTOP-AA2AV04 440KB
events.out.tfevents.1525813106.DESKTOP-AA2AV04 434KB
events.out.tfevents.1525810794.DESKTOP-AA2AV04 433KB
events.out.tfevents.1525812917.DESKTOP-AA2AV04 432KB
.gitattributes 66B
cnn_model_keras.h5 25.16MB
full_img.jpg 31KB
470.jpg 4KB
498.jpg 4KB
465.jpg 4KB
440.jpg 4KB
447.jpg 4KB
469.jpg 4KB
451.jpg 4KB
483.jpg 4KB
499.jpg 4KB
460.jpg 4KB
463.jpg 4KB
212.jpg 4KB
446.jpg 4KB
482.jpg 4KB
450.jpg 4KB
449.jpg 4KB
183.jpg 4KB
468.jpg 4KB
437.jpg 4KB
458.jpg 4KB
448.jpg 4KB
466.jpg 4KB
486.jpg 4KB
335.jpg 4KB
462.jpg 4KB
496.jpg 4KB
487.jpg 4KB
464.jpg 4KB
484.jpg 4KB
456.jpg 4KB
459.jpg 4KB
445.jpg 4KB
188.jpg 4KB
436.jpg 4KB
485.jpg 4KB
478.jpg 4KB
347.jpg 4KB
472.jpg 4KB
471.jpg 4KB
285.jpg 4KB
459.jpg 4KB
497.jpg 4KB
454.jpg 4KB
457.jpg 4KB
434.jpg 4KB
433.jpg 4KB
344.jpg 4KB
452.jpg 4KB
479.jpg 4KB
489.jpg 4KB
492.jpg 4KB
187.jpg 4KB
303.jpg 4KB
439.jpg 4KB
318.jpg 4KB
444.jpg 4KB
490.jpg 4KB
481.jpg 4KB
185.jpg 4KB
467.jpg 4KB
197.jpg 4KB
198.jpg 4KB
495.jpg 4KB
477.jpg 4KB
461.jpg 4KB
453.jpg 4KB
319.jpg 4KB
443.jpg 4KB
442.jpg 4KB
491.jpg 4KB
208.jpg 4KB
435.jpg 4KB
336.jpg 4KB
64.jpg 4KB
184.jpg 3KB
345.jpg 3KB
70.jpg 3KB
480.jpg 3KB
218.jpg 3KB
199.jpg 3KB
441.jpg 3KB
319.jpg 3KB
315.jpg 3KB
468.jpg 3KB
355.jpg 3KB
493.jpg 3KB
290.jpg 3KB
共 5540 条
- 1
- 2
- 3
- 4
- 5
- 6
- 56
资源评论
weixin_39840515
- 粉丝: 446
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功