Skip to content

Commit

Permalink
Add docstring for some rmn utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Pham committed Jul 13, 2021
1 parent 7c6b4e6 commit b77abb6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Facial Expression Recognition using Residual Masking Network, in PyTorch

[![pypi package](https://img.shields.io/badge/version-v3.0.1-blue)](https://pypi.org/project/rmn)
[![pypi package](https://img.shields.io/badge/version-v3.0.2-blue)](https://pypi.org/project/rmn)
[![circleci](https://circleci.com/gh/phamquiluan/ResidualMaskingNetwork.svg?style=shield&circle-token=3ca7f15b6bd362b625bec536d57c45fe5ef6f2c9)](https://app.circleci.com/pipelines/github/phamquiluan/ResidualMaskingNetwork)
[![style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/phamquiluan/residualmaskingnetwork)
[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/challenges-in-representation-learning-a/facial-expression-recognition-on-fer2013)](https://paperswithcode.com/sota/facial-expression-recognition-on-fer2013?p=challenges-in-representation-learning-a)
Expand Down
28 changes: 28 additions & 0 deletions rmn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,23 @@ def __init__(self, face_detector=True):

@torch.no_grad()
def detect_emotion_for_single_face_image(self, face_image):
"""
Params:
-----------
face_image : np.ndarray
a cropped face image
Return:
-----------
emo_label : str
dominant emotion label
emo_proba : float
dominant emotion proba
proba_list : list
all emotion label and their proba
"""
assert isinstance(face_image, np.ndarray)
face_image = ensure_color(face_image)
face_image = cv2.resize(face_image, image_size)
Expand Down Expand Up @@ -204,6 +221,17 @@ def video_demo(self):

@staticmethod
def draw(frame, results):
"""
Params:
---------
frame : np.ndarray
results : list of dict.keys('xmin', 'xmax', 'ymin', 'ymax', 'emo_label', 'emo_proba')
Returns:
---------
frame : np.ndarray
"""
for r in results:
xmin = r["xmin"]
xmax = r["xmax"]
Expand Down

0 comments on commit b77abb6

Please sign in to comment.