Skip to content

Commit

Permalink
Merge d0f4b58 into 7209b99
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheong0428 committed Mar 27, 2021
2 parents 7209b99 + d0f4b58 commit bccfc52
Show file tree
Hide file tree
Showing 61 changed files with 6,394 additions and 213 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,9 @@
language: python
python:
- 3.6
- 3.7
- 3.8
- 3.9

dist: xenial
services:
Expand Down
1 change: 1 addition & 0 deletions README.md
@@ -1,4 +1,5 @@
# Py-FEAT
[![Package versioning](https://img.shields.io/pypi/v/py-feat.svg)](https://pypi.org/project/py-feat/)
[![Build Status](https://api.travis-ci.org/cosanlab/feat.svg?branch=master)](https://travis-ci.org/cosanlab/feat/)
[![Coverage Status](https://coveralls.io/repos/github/cosanlab/py-feat/badge.svg?branch=master)](https://coveralls.io/github/cosanlab/py-feat?branch=master)
Python Facial Expression Analysis Toolbox (FEAT)
Expand Down
22 changes: 1 addition & 21 deletions feat/detector.py
Expand Up @@ -634,7 +634,7 @@ def detect_video(self, inputFname, outputFname=None, skip_frames=1, verbose=Fals
emotion_columns=FEAT_EMOTION_COLUMNS,
facebox_columns=FEAT_FACEBOX_COLUMNS,
landmark_columns=openface_2d_landmark_columns,
time_columns=FACET_TIME_COLUMNS,
time_columns=FEAT_TIME_COLUMNS,
detector="Feat",
)

Expand Down Expand Up @@ -688,23 +688,3 @@ def detect_image(self, inputFname, outputFname=None, verbose=False):
time_columns=FACET_TIME_COLUMNS,
detector="Feat",
)
# %%
# Test case:
if __name__ == '__main__':
A01 = Detector(face_model='RetinaFace',emotion_model='svm', landmark_model="MobileFaceNet", au_model='rf')
test_img = cv2.imread(r"F:\test_case\JinHyunCheong.jpg")
im01 = Image.open(r"F:\test_case\JinHyunCheong.jpg")
detected_faces = A01.detect_faces(frame=test_img)
landmarks = A01.detect_landmarks(
frame=test_img, detected_faces=[detected_faces[0][0:4]]
)
ress = A01.detect_image(r"F:\test_case\JinHyunCheong.jpg")
print(ress)
#convex_hull, new_lands = A01.extract_face(frame=test_img, detected_faces=detected_faces[0], landmarks=landmarks, size_output=112)
#bk01,bk02 = A01.extract_hog(frame=convex_hull,visualize=True)
#A02 = LogisticClassifier()
#probbs = A02.detect_au(bk01, new_lands)
#print(probbs)
print("yes")
ress.plot_detections();
# %%
23 changes: 23 additions & 0 deletions feat/tests/test_detector.py
Expand Up @@ -12,6 +12,7 @@
import os
import cv2
import numpy as np
import pytest

inputFname = os.path.join(get_test_data_path(), "input.jpg")
img01 = cv2.imread(inputFname)
Expand Down Expand Up @@ -211,6 +212,28 @@ def test_resmasknet():
out = detector1.detect_image(inputFname)
assert out.emotions()["happiness"].values > 0.5

def test_emotionsvm():
inputFname = os.path.join(get_test_data_path(), "input.jpg")
detector1 = Detector(emotion_model="svm")
out = detector1.detect_image(inputFname)
assert out.emotions()["happiness"].values > 0.5

def test_emotionrf():
# Emotion RF models is not good
inputFname = os.path.join(get_test_data_path(), "input.jpg")
detector1 = Detector(emotion_model="rf")
out = detector1.detect_image(inputFname)
assert out.emotions()["happiness"].values > 0.0

def test_wrongmodelname():
with pytest.raises(KeyError):
detector1 = Detector(emotion_model="badmodelname")

def test_nofile():
with pytest.raises(FileNotFoundError):
inputFname = os.path.join(get_test_data_path(), "nosuchfile.jpg")
detector1 = Detector(emotion_model="svm")
out = detector1.detect_image(inputFname)

def test_detect_image():
# Test detect image
Expand Down
6 changes: 6 additions & 0 deletions feat/tests/test_utils.py
Expand Up @@ -10,6 +10,7 @@
from os.path import join, exists
from .utils import get_test_data_path
from feat.utils import (
read_feat,
read_facet,
read_openface,
read_affectiva,
Expand All @@ -18,10 +19,15 @@
softmax,
load_h5,
)
from feat import Fex
from nltools.data import Adjacency
import unittest


def test_read_feat():
fex = read_feat(join(get_test_data_path(), "output.csv"))
assert type(fex) == Fex

def test_utils():
sample = read_openface(join(get_test_data_path(), "OpenFace_Test.csv"))
lm_cols = ["x_" + str(i) for i in range(0, 68)] + [
Expand Down
3 changes: 2 additions & 1 deletion feat/utils.py
Expand Up @@ -241,10 +241,11 @@ def read_feat(fexfile):
Fex of processed facial expressions
"""
d = pd.read_csv(fexfile)
au_columns = [col for col in d.columns if "AU" in col]
return feat.Fex(
d,
filename=fexfile,
au_columns=jaanet_AU_presence,
au_columns=au_columns,
emotion_columns=FEAT_EMOTION_COLUMNS,
landmark_columns=openface_2d_landmark_columns,
facebox_columns=FEAT_FACEBOX_COLUMNS,
Expand Down
Binary file modified notebooks/_build/.doctrees/content/analysis.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified notebooks/_build/.doctrees/content/intro.doctree
Binary file not shown.
Binary file modified notebooks/_build/.doctrees/environment.pickle
Binary file not shown.
Binary file modified notebooks/_build/html/_images/analysis_17_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 140 additions & 46 deletions notebooks/_build/html/_sources/content/analysis.ipynb

Large diffs are not rendered by default.

754 changes: 754 additions & 0 deletions notebooks/_build/html/_sources/content/dev_plotting.ipynb

Large diffs are not rendered by default.

481 changes: 481 additions & 0 deletions notebooks/_build/html/_sources/content/dev_trainAUvisModel.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions notebooks/_build/html/_sources/content/intro.md
@@ -1,11 +1,11 @@
Py-Feat: Python Facial Expression Analysis Toolbox
============================

[![Build Status](https://api.travis-ci.org/cosanlab/feat.svg?branch=master)](https://travis-ci.org/cosanlab/feat/)
[![Package versioning](https://img.shields.io/pypi/v/py-feat.svg)](https://pypi.org/project/py-feat/)
[![Build Status](https://api.travis-ci.org/cosanlab/py-feat.svg?branch=master)](https://travis-ci.org/cosanlab/py-feat/)
[![Coverage Status](https://coveralls.io/repos/github/cosanlab/py-feat/badge.svg?branch=master)](https://coveralls.io/github/cosanlab/py-feat?branch=master)
[![GitHub forks](https://img.shields.io/github/forks/cosanlab/py-feat)](https://github.com/cosanlab/feat/network)
[![GitHub stars](https://img.shields.io/github/stars/cosanlab/py-feat)](https://github.com/cosanlab/feat/stargazers)
[![GitHub license](https://img.shields.io/github/license/cosanlab/py-feat)](https://github.com/cosanlab/feat/blob/master/LICENSE)
[![GitHub forks](https://img.shields.io/github/forks/cosanlab/py-feat)](https://github.com/cosanlab/py-feat/network)
[![GitHub stars](https://img.shields.io/github/stars/cosanlab/py-feat)](https://github.com/cosanlab/py-feat/stargazers)
[![GitHub license](https://img.shields.io/github/license/cosanlab/py-feat)](https://github.com/cosanlab/py-feat/blob/master/LICENSE)

Py-Feat provides a comprehensive set of tools and models to easily detect facial expressions (Action Units, emotions, facial landmarks) from images and videos, preprocess & analyze facial expression data, and visualize facial expression data.

Expand Down
83 changes: 78 additions & 5 deletions notebooks/_build/html/content/analysis.html
Expand Up @@ -369,8 +369,8 @@ <h1 class="site-logo" id="site-title">Py-Feat</h1>
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#intersubject-correlations">
Intersubject correlations
<a class="reference internal nav-link" href="#intersubject-or-intervideo-correlations">
Intersubject (or intervideo) correlations
</a>
</li>
</ul>
Expand Down Expand Up @@ -894,6 +894,11 @@ <h2>Simple t-test<a class="headerlink" href="#simple-t-test" title="Permalink to
<td>-49.805912</td>
<td>2.660164e-12</td>
</tr>
<tr>
<th>mean_AU05</th>
<td>-11.942339</td>
<td>8.022300e-07</td>
</tr>
<tr>
<th>mean_AU06</th>
<td>3.905366</td>
Expand All @@ -904,11 +909,21 @@ <h2>Simple t-test<a class="headerlink" href="#simple-t-test" title="Permalink to
<td>5.487334</td>
<td>3.864728e-04</td>
</tr>
<tr>
<th>mean_AU09</th>
<td>-22.647961</td>
<td>3.024835e-09</td>
</tr>
<tr>
<th>mean_AU10</th>
<td>10.361594</td>
<td>2.660301e-06</td>
</tr>
<tr>
<th>mean_AU11</th>
<td>-42.691265</td>
<td>1.059418e-11</td>
</tr>
<tr>
<th>mean_AU12</th>
<td>11.949046</td>
Expand All @@ -929,6 +944,11 @@ <h2>Simple t-test<a class="headerlink" href="#simple-t-test" title="Permalink to
<td>-0.460219</td>
<td>6.562759e-01</td>
</tr>
<tr>
<th>mean_AU20</th>
<td>-45.470892</td>
<td>6.019391e-12</td>
</tr>
<tr>
<th>mean_AU23</th>
<td>-0.300423</td>
Expand All @@ -939,6 +959,26 @@ <h2>Simple t-test<a class="headerlink" href="#simple-t-test" title="Permalink to
<td>-4.533345</td>
<td>1.419377e-03</td>
</tr>
<tr>
<th>mean_AU25</th>
<td>3.119502</td>
<td>1.232852e-02</td>
</tr>
<tr>
<th>mean_AU26</th>
<td>-5.015769</td>
<td>7.232461e-04</td>
</tr>
<tr>
<th>mean_AU28</th>
<td>-7.169935</td>
<td>5.251451e-05</td>
</tr>
<tr>
<th>mean_AU43</th>
<td>-78.139016</td>
<td>4.660607e-14</td>
</tr>
</tbody>
</table>
</div></div></div>
Expand Down Expand Up @@ -1076,15 +1116,23 @@ <h2>Regression<a class="headerlink" href="#regression" title="Permalink to this
<th>AU01</th>
<th>AU02</th>
<th>AU04</th>
<th>AU05</th>
<th>AU06</th>
<th>AU07</th>
<th>AU09</th>
<th>AU10</th>
<th>AU11</th>
<th>AU12</th>
<th>AU14</th>
<th>AU15</th>
<th>AU17</th>
<th>AU20</th>
<th>AU23</th>
<th>AU24</th>
<th>AU25</th>
<th>AU26</th>
<th>AU28</th>
<th>AU43</th>
</tr>
</thead>
<tbody>
Expand All @@ -1093,30 +1141,46 @@ <h2>Regression<a class="headerlink" href="#regression" title="Permalink to this
<td>0.066</td>
<td>0.052</td>
<td>-0.065</td>
<td>-0.251</td>
<td>0.497</td>
<td>0.291</td>
<td>0.105</td>
<td>0.408</td>
<td>-0.002</td>
<td>0.569</td>
<td>0.022</td>
<td>0.111</td>
<td>0.101</td>
<td>0.038</td>
<td>-0.029</td>
<td>-0.284</td>
<td>0.305</td>
<td>0.140</td>
<td>-0.016</td>
<td>0.013</td>
</tr>
<tr>
<th>t-stats</th>
<td>8.221</td>
<td>8.219</td>
<td>-17.153</td>
<td>-31.413</td>
<td>43.783</td>
<td>33.364</td>
<td>21.079</td>
<td>35.625</td>
<td>-2.671</td>
<td>46.713</td>
<td>4.088</td>
<td>17.515</td>
<td>15.673</td>
<td>7.927</td>
<td>-5.063</td>
<td>-22.483</td>
<td>19.415</td>
<td>16.822</td>
<td>-2.293</td>
<td>2.422</td>
</tr>
<tr>
<th>p-values</th>
Expand All @@ -1128,19 +1192,28 @@ <h2>Regression<a class="headerlink" href="#regression" title="Permalink to this
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.008</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.000</td>
<td>0.022</td>
<td>0.016</td>
</tr>
</tbody>
</table>
</div></div></div>
</div>
</div>
<div class="section" id="intersubject-correlations">
<h2>Intersubject correlations<a class="headerlink" href="#intersubject-correlations" title="Permalink to this headline"></a></h2>
<p>To compare the similarity of signals over time between subjects or videos, you can use the <code class="docutils literal notranslate"><span class="pre">isc</span></code> method. You can get a sense of how much two signals, such as a certain action unit activity, correlates over time. For example, if you want to see how AU01 activations are similar across the videos, you can do the following which shows that the temporal profile of AU01 activations form two clusters between the goodNews and the badNews conditions.</p>
<div class="section" id="intersubject-or-intervideo-correlations">
<h2>Intersubject (or intervideo) correlations<a class="headerlink" href="#intersubject-or-intervideo-correlations" title="Permalink to this headline"></a></h2>
<p>To compare the similarity of signals over time between subjects or videos, you can use the <code class="docutils literal notranslate"><span class="pre">isc</span></code> method. You can get a sense of how much two signals, such as a certain action unit activity, correlates over time.</p>
<p>In this example, we are calculating the ISC over videos. We want to check how similar AU01 activations are across videos so our session is set to the <code class="docutils literal notranslate"><span class="pre">input</span></code> which is the video name. Executing the <code class="docutils literal notranslate"><span class="pre">isc</span></code> method shows that the temporal profile of AU01 activations form two clusters between the goodNews and the badNews conditions.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">fex</span><span class="o">.</span><span class="n">sessions</span> <span class="o">=</span> <span class="n">fex</span><span class="o">.</span><span class="n">input</span><span class="p">()</span>
Expand Down
5 changes: 0 additions & 5 deletions notebooks/_build/html/content/contribute.html
Expand Up @@ -130,11 +130,6 @@ <h1 class="site-logo" id="site-title">Py-Feat</h1>
Analyzing FEX data
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="analysis.html#two-sample-independent-t-test">
Two sample independent t-test
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="plotting.html">
Plotting examples
Expand Down
5 changes: 0 additions & 5 deletions notebooks/_build/html/content/detector.html
Expand Up @@ -131,11 +131,6 @@ <h1 class="site-logo" id="site-title">Py-Feat</h1>
Analyzing FEX data
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="analysis.html#two-sample-independent-t-test">
Two sample independent t-test
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="plotting.html">
Plotting examples
Expand Down

0 comments on commit bccfc52

Please sign in to comment.