Giter Club home page Giter Club logo

emotic's Introduction

Emotic

Humans use their facial features or expressions to convey how they feel, such as a person may smile when happy and scowl when angry. Historically, computer vision research has focussed on analyzing and learning these facial features to recognize emotions. However, these facial features are not universal and vary extensively across cultures and situations.

Fig 1: a) (Facial feature) The person looks angry or in pain b) (Whole scene) The person looks elated.

A scene context, as shown in the figure above, can provide additional information about the situations. This project explores the use of context in recognizing emotions in images.

Pipeline

The project uses the EMOTIC dataset and follows the methodology as introduced in the paper 'Context based emotion recognition using EMOTIC dataset'.

Pipeline

Fig 2: Model Pipeline (Image source)

Two feature extraction modules first extract features over an image. These features are then used by a third module to predict the continuous dimensions (valence, arousal and dominance) and the discrete emotion categories.

Emotic Dataset

The Emotic dataset can be used only for non-commercial research and education purposes. Please, fill out the following form to request access to the dataset and the corresponding annotations.

Access Request for EMOTIC

Usage

Download the Emotic dataset & annotations, and prepare the directory following the below structure:

├── ...
│   ├── emotic
│   |    ├── ade20k
│   |    ├── emodb_small
│   |    ├── framesdb
│   |    ├── mscoco 
│   ├── Annotations
│   |    ├── Annotations.mat
  1. To convert annotations from mat object to csv files and preprocess the data:
> python mat2py.py --data_dir proj/data/emotic19 --generate_npy
  • data_dir: Path of the directory containing the emotic and annotations folder as described in the above data directory structure.
  • generate_npy: Argument to specify to generate npy files (later used for training and testing) along with CSV files. If not passed only CSV files are generated.
  1. To train the model:
> python main.py --mode train --data_path proj/data/emotic_pre --experiment_path proj/debug_exp
  • mode: Mode to run the main file.
  • data_path: Path of the directory which contains the preprocessed data and CSV files generated in the first step.
  • experiment_path: Path of the experiment directory. The directory will save the results, models and logs.
  1. To test the model:
> python main.py --mode test --data_path proj/data/emotic_pre --experiment_path proj/debug_exp
  • mode: Mode to run the main file.
  • data_path: Path of the directory which contains the preprocessed data and CSV files generated in the first step.
  • experiment_path: Path of the experiment directory. Models stored in the the directory are used for testing.
  1. To perform inference:
> python main.py --mode inference --inference_file proj/debug_exp/inference_file.txt --experiment_path proj/debug_exp
  • mode: Mode to run the main file.
  • inference_file: Text file specifying images to perform inference. A row is: 'full_path_of_image x1 y1 x2 y2', where (x1,y1) and (x2,y2) specify the bounding box. Refer sample_inference_list.txt.
  • experiment_path: Path of the experiment directory. Models stored in the the directory are used for inference.

You can also train and test models on Emotic dataset by using the Colab_train_emotic notebook. Open In Colab

The trained models and thresholds to use for inference purposes are availble here.

Results

Result GIF 1

Acknowledgements

Context Based Emotion Recognition using Emotic Dataset

Ronak Kosti, Jose Alvarez, Adria Recasens, Agata Lapedriza
[Paper] [Project Webpage] [Authors' Implementation]

@article{kosti2020context,
  title={Context based emotion recognition using emotic dataset},
  author={Kosti, Ronak and Alvarez, Jose M and Recasens, Adria and Lapedriza, Agata},
  journal={arXiv preprint arXiv:2003.13401},
  year={2020}
}

Author

Abhishek Tandon

emotic's People

Contributors

tandon-a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

emotic's Issues

Is there preprocessed data available?

Hi,

I'm sorry to bother again. I don't know if it's possible to have access to the preprocessed data. I guess there are something wrong with my running. I always get an mAP of 0.21.

Best regards,
Hui

dataset

The link you shared with Google Drive has expired, can you share it again? Thank you.

Problem with EMOTIC dataset

I found almost half of the bounding boxes are not correct where the boxes do not bind the full person after I visualized the pictures.

Why I got low mAP comparing with that in paper?

Hi,
I ran the training step and got the models, then I ran test and the mAP was only 0.20610.
Firstly, I thought maybe it's because of my bad training. So I downloaded given trained models and thresholds and the mAP of test step is still low.
Then I thought about preprocessing step of dataset, I received errors like: libpng warning: iCCP: known incorrect sRGB profile, libpng warning: iCCP: extra compressed data and Corrupt JPEG data: 44 extraneous bytes before marker 0xd9, I don't know whether they have some bad influence.
Then I saw the result of test step from this notebook. It looks similar to my result. But I wonder why mAP is quite different from that in paper.
I'd appreciate if you could give me some hints.

Best regards,
Hui

About Projects

您好,最近在学习相关知识,请问融合然后网络发生变化了吗?修改的主要部分是什么呢?期待您的回答,谢谢。

Training script isn't working

when I run this command
python main.py --mode train --data_path proj/data/emotic_pre --experiment_path proj/debug_exp

the main.py script is opened in notepad++ and nothing else happends

Any help

Unabled to create training data

When running the following command:

 python mat2py.py --data_dir ~/Desktop/passion/data/Annotations --generate_npy --label train

While the csv is generated, the process gets killed before it can generate the npy files.

libpng warning: iCCP: known incorrect sRGB profile
 Preprocessing data. Index =  22000
 Preprocessing data. Index =  23000
81 0 359
wrote file  /home/amittel/Desktop/proj/data/Annotations/emotic_pre/train.csv
Killed

loading model

Hi Abhishek!

I have downloaded the pretrained model but here there are three models in this case, but I try to load them and get the error could you help me regarding this please and how do i predict once I have got the model loaded.

image

Problem with inference

Hello,
I have a question about the threshold which you used.
First, I try to calculate thresholds where precision is equal to recall. After that, results from model will compare with it to become array [1, 0, ...0]. If I continue with it and use the function "average_precision_score", I will get another meanAP.
Did I do any wrong steps?

AttributeError: Can't get attribute 'Emotic' on <module '__main__' from 'main.py'>

while loading pretrained 'model_emotic1.pth'
getting this error

mode inference
Traceback (most recent call last):
File "main.py", line 102, in
inference_emotic(args.inference_file, model_path, result_path, context_norm, body_norm, ind2cat, ind2vad, args)
File "E:\emotic-master\inference.py", line 110, in inference_emotic
emotic_model = torch.load(os.path.join(model_path,'model_emotic1.pth')).to(device)
File "C:\Python\Python36\lib\site-packages\torch\serialization.py", line 592, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "C:\Python\Python36\lib\site-packages\torch\serialization.py", line 851, in _load
result = unpickler.load()
AttributeError: Can't get attribute 'Emotic' on <module 'main' from 'main.py'>

TypeError: the first argument must be callable

Traceback (most recent call last):
File "main.py", line 86, in
train_emotic(result_path, model_path, train_log_path, val_log_path, ind2cat, ind2vad, context_norm, body_norm, args)
File "D:\2022-next\2022-text\emotic-master\train.py", line 174, in train_emotic
model_context, model_body = prep_models(context_model=args.context_model, body_model=args.body_model, model_dir=model_path)
File "D:\2022-next\2022-text\emotic-master\prepare_models.py", line 28, in prep_models
model = torch.load(model_file, map_location=lambda storage, loc: storage, pickle_module=pickle)
File "D:\anaconda3\envs\pytorch114\lib\site-packages\torch\serialization.py", line 795, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "D:\anaconda3\envs\pytorch114\lib\site-packages\torch\serialization.py", line 820, in _legacy_load
class UnpicklerWrapper(pickle_module.Unpickler): # type: ignore[name-defined]
TypeError: the first argument must be callable

The Problem of setting threshold of discrete emotions

According to the paper, the threshold of discrete emotion recognition is set as Precision=Recall. Why is it set like this? How did you get this value? Did you get it through training?
What do the values of the elements [1,26] represent when you enter a picture? It doesn't mean accuracy, does it?
I am a novice, hope to get your answer, thank you!

TypeError: the first argument must be callable

(emotic) root@autodl-container-919011829e-7f6a3e29:~/autodl-tmp/emotic-master# python main.py --mode train --data_path data/Emotic/emotic_pre --experiment_path proj/debug_exp
mode train
train context (23266, 224, 224, 3) body (23266, 128, 128, 3) cat (23266, 26) cont (23266, 3)
val context (3315, 224, 224, 3) body (3315, 128, 128, 3) cat (3315, 26) cont (3315, 3)
train loader 448 val loader 64
Traceback (most recent call last):
File "main.py", line 88, in
train_emotic(result_path, model_path, train_log_path, val_log_path, ind2cat, ind2vad, context_norm, body_norm, args)
File "/root/autodl-tmp/emotic-master/train.py", line 174, in train_emotic
model_context, model_body = prep_models(context_model=args.context_model, body_model=args.body_model, model_dir=model_path)
File "/root/autodl-tmp/emotic-master/prepare_models.py", line 26, in prep_models
model = torch.load(model_file, map_location=lambda storage, loc: storage, pickle_module=pickle)
File "/root/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/root/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 738, in _legacy_load
class UnpicklerWrapper(pickle_module.Unpickler): # type: ignore[name-defined]
TypeError: the first argument must be callable

question about thresholds

Hello, I would like to consult you. As mentioned in your code, threshold value can be used to help infer. I am not quite clear how this is used to infer.Looking forward to your reply.Thank you!

TypeError: the first argument must be callable How to resolve this?

mode train
tcmalloc: large alloc 3502186496 bytes == 0x55b885002000 @ 0x7f8f31a3a1e7 0x7f8f2f5ba46e 0x7f8f2f60ee7c 0x7f8f2f60faaf 0x7f8f2f6b1470 0x55b87ecc1544 0x55b87ecc1240 0x55b87ed35627 0x55b87ed2f9ee 0x55b87ecc2bda 0x55b87ed31737 0x55b87ed2f9ee 0x55b87ecc2bda 0x55b87ed34d00 0x55b87ecc2afa 0x55b87ed30915 0x55b87ed2f9ee 0x55b87ed2f6f3 0x55b87edf94c2 0x55b87edf983d 0x55b87edf96e6 0x55b87edd1163 0x55b87edd0e0c 0x7f8f30824bf7 0x55b87edd0cea
train context (23266, 224, 224, 3) body (23266, 128, 128, 3) cat (23266, 26) cont (23266, 3)
val context (3315, 224, 224, 3) body (3315, 128, 128, 3) cat (3315, 26) cont (3315, 3)
train loader 448 val loader 64
data/experiment/models/resnet18_places365.pth.tar
Traceback (most recent call last):
File "main.py", line 87, in
train_emotic(result_path, model_path, train_log_path, val_log_path, ind2cat, ind2vad, context_norm, body_norm, args)
File "/content/gdrive/My Drive/Deep learning Models/emotic-master/emotic-master/train.py", line 174, in train_emotic
model_context, model_body = prep_models(context_model=args.context_model, body_model=args.body_model, model_dir=model_path)
File "/content/gdrive/My Drive/Deep learning Models/emotic-master/emotic-master/prepare_models.py", line 32, in prep_models
checkpoint = torch.load(save_file, map_location=lambda storage, loc: storage) # model trained in GPU could be deployed in CPU machine like this!
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 869, in _load
class UnpicklerWrapper(pickle_module.Unpickler): # type: ignore[name-defined]
TypeError: the first argument must be callable

Continuous Dimension metrics

Mean VAD Error is quite high.. I am getting below values:

Continuous Valence 0.73813
Continuous Arousal 0.94274
Continuous Dominance 0.92793
Mean VAD Error 0.86960

Can you please explain any possible reason?

(x1,y1) and (x2,y2) the bounding box

How do inference_file.txt get,the sample-inference_file.txt file given in the project? Also, (x1,y1) and (x2,y2) specify where the bounding box comes from? Thank you so much!

yolo.utils.py

in yolo_utils.py 316 lines
if targets is None:
return output, 0
else:
iou_scores, class_mask, obj_mask, noobj_mask, tx, ty, tw, th, tcls, tconf = build_targets(
pred_boxes=pred_boxes,
pred_cls=pred_cls,
target=targets,
anchors=self.scaled_anchors,
ignore_thres=self.ignore_thres,
)
Unresolved reference 'build_targets' ,display undefined.
Also, do I need to inference_list.txt files when yolo_inference.py test videos? Where to get the file if needed, mine came out with poor results if it wasn't needed

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.