Coder Social home page Coder Social logo

cherrypiecoco / emotiondetection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amr4i/emotiondetection

0.0 0.0 0.0 16.63 MB

An emotion extraction system for images, that extracts emotion which will be felt by the user of viewing the image, representing them in a 2-Dimensional space that represents Arousal and Valence.

Python 79.30% Makefile 1.01% C++ 19.69%

emotiondetection's Introduction

EmotionDetection

This is a python implementation for extracting arousal and valence values from images, as presented in the work: Building Emotional Machines: Recognizing Image Emotions through Deep Neural Networks by Hye-Rin Kim, Yeong-Seok Kim, Seon Joo Kim, In-Kwon Lee.

Pre-requisites

  1. Make sure openCV is installed on both python and C++. Here is a tutorial to installing OpenCV on C++.
  2. Tensorflow
  3. scikit-learn

Instructions

Training

  1. To avoid loading of model weights again and again, we first pre-compute certain features for all images, that will be used in making the feature vector of the image.

    • GIST Feature Extraction:

      • Run the code segment:
       	cd GIST 
       	make IMAGEPATH=<path_to_directory_containing_all_images>
       	make clean
      
      • This will create a file in the main folder named gists.txt, that contains the GIST descriptor of each image, one per line, in the format: <FILENAME>:<GIST_Descriptor>
    • VGG Object Feature Extraction:

      • For the following command, imageFile = a file containing names of images and their A/V values separated by a comma, and imagesDir = the folder containing all training images. Run the code segment:

         	cd VGG
         	python vgg16.py <imageFile> <imagesDir> <VGG_weights>
        
      • This will create a pickle in the main folder named vgg.pickle, that holds a python dictionary with names of images being mapped to their VGG object features.

      • More information about this VGG Descriptor can be found here.

    • Semantic Features Extraction:

      • Run the file test.py in the semantic_features folder, providing 4 python arguments, namely: test_img_file, test_img_directory, weights_encoder and weights_decoder.
  2. Now, using these extracted features, and more (LBP features), we will be constructing a feature vector for each training image.

  3. Set the training parameters in the file params.json, as required.

  4. Run the training file:

	python train.py <imageFile> <imagesDir>
  1. This will store the model in a modelData named directory, in the parent directory of the current folder. The name of folder in which contains a timestamp that will be used to recognise the stored model during the prediction.

Prediction

  1. Again, go through the entire process of feature exrraction for the images for which the prediction needs to be made.

  2. Set the prediction parameters in the file test_params.json, as required.

  3. Run the prediction code:

	python predict.py <testImageFile> <testImgDir> <timestamp>

where testImageFile=file containing names of all images to be predicted for, testImgDir=directory containing all images to predicted for, timestamp=the timestamp of the model to be used for prediction.

emotiondetection's People

Contributors

amr4i 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.