GithubHelp home page GithubHelp logo

jinsung4069 / emotionnet2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from co60ca/emotionnet2

0.0 0.0 0.0 27 KB

EmotionNet2 convolutional neural network for expression recognition

License: GNU General Public License v3.0

Python 100.00%

emotionnet2's Introduction

EmotionNet2

Building on EmotionNet we improve generalization by improving the way we handle our input data.

What is EmotionNet?

EmotionNet is an application of Convolutional Neural Networks to emotion recognition in photographs of human faces. EmotionNet2 does face detection in addition to classification to assist in reducing variance due to backgroud noise. See the original EmotionNet. There is no web interface for this version as was present in the original version.

Support

You should please note that no support is guaranteed and only best effort is provided. I will gladly accept reasonable patches and would like to hear if documentation/instructions are unclear. By no means are the instructions 100% foolproof but I expect you to be able to have some understanding of Python, and Linux environments.

Instructions

  1. Install requirements, including requirements.txt. Use pip3 --requirement requirements.txt. Additionally, you need pytorch gpu.

Follow either Pretrained or Train Yourself streams after completing the requirements.

Pretrained

  1. Download the external checkpoint from my server and place in the root directory.
  2. Then, decompress using gzip, gunzip checkpoint.pth.tar.gz (removes .gz extension)
  3. Start python3 from the root directory with the PYTHONPATH=python as the python scripts are in the python directory.
  4. To try one image you can do the following:
import emotionnet
net = emotionnet.EmotionNet(layers=[3, 4, 23, 3])
net.load_checkpoint('checkpoint.pth.tar')
net.classify_one_image('filename of image.jpg')

To run this as a service you would want to keep the checkpoint loaded in memory as it takes some time to load.

Train Yourself

  1. In order to train you will need KDEF the scripts expect the file References.txt in the KDEF distribution to be in KDEF/References.txt from the root of the project.

  2. Once you have KDEF data you need to split the data up into training/validation/testing and extract the faces from the KDEF data.

  3. Run PYTHONPATH=python python3 python/extract_faces.py which extracts the faces into train/

  4. Run PYTHONPATH=python python3 python/split_dataset.py which splits into train/test/valid

  5. Finally run a trainer. This will take some time. It is recommended to make a file containing the below called train.sh and run this file. Set tname on the first line to whatever you like. The tname will be your checkpoint.pth.tar from the pretrained.

tname=model-01
PYTHONPATH=$PYTHONPATH python3 <<HEAD
import emotionnet
net = emotionnet.EmotionNet(layers=[3, 4, 23, 3])
net.train_model('train', 'valid', '$tname', epochs=200, csvout='${tname}-csv.csv')
net.load_checkpoint('best-${tname}.pth.tar')
net.valid_model('valid')
HEAD
  1. Now you've trained your model, follow the pretrained instructions from step 4. using your checkpoint file and not the checkpoint.pth.tar. Your best model will start with best-

emotionnet2's People

Contributors

co60ca avatar huberemanuel avatar andreymgn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.