Skip to content

[Python] Create your first CLI app with Facial Expression Recognition

Step by step example to run Mojo Facial Expression API for CLI application.


In this tutorial, we will go through the process of building a command line interface app and mostly focusing on plugging the facial expression recognition API and print the result.

Open Source Tutorial : available on GitHub

You can find all the source code and documentation on GitHub

Install the library

Mojo Facial Expression Python API is available on

pip install mojoperception

mojoperception update

You can update mojoperception using pip command :

pip install --upgrade mojoperception

Clone the project

In your work directory, clone the project :

git clone

Get a fresh API token

Mojo Facial Expression API is accessible through Authorization token.

If you don't have an account yet

👉   Create your developer account, and get access to a 14-days free trial :
After registering, you'll receive your API Key. We'll need it right away.

Adjust code example example/

Use the "API_KEY" in the following code section example/

// Replace with your <API_KEY>
mojo_perception = MojoPerceptionAPI("<API_KEY>")

Run enjoy the example

🎉 You're done.

Run the example, and watch the "Attention" value print in the console. Try looking away, and you will see the prediction change accordingly

python example/

Customize the example

You can add callbacks on each emotions, add new emotions and enhance design to build your very own application.


1️⃣   If you face a "JsonWebTokenError", maybe that's because of the expiration. You can try to increase the user token duration to match your need. Default value of 360 seconds might be too short.

2️⃣   If you have some python version issues, check your python version. Minimum version is python 3.6

Check the usage of your API Key

Open the Mojo Facial Expression API Backoffice to check your consumption, and manage your account.