Skip to content

4. How to use

Maneesh edited this page Dec 27, 2024 · 6 revisions

Running PyAFAR

PyAFAR offers a GUI and a Python interface for domain experts and computational users.

GUI usage

In your terminal run PyAFAR_GUI to invoke the GUI and follow the below instructions.

The basic settings is the default configuration that provides all possible outputs including person-tracking for all videos in the folder. If you need a specific set of AUs or have a large number of videos and want to save time, click on the advanced settings tab to select your requirements.

Basic settings

Basic settings

These are necessary settings that include path to videos to process, save and other information.

  • Input Videos: path to the folder containing videos that need to be processed
  • Save Folder: path to save the output from PyAFAR for the input videos
  • Browse button enables browsing and selecting the folders interactively
  • PyAFAR version: Since adult and infant AU predictions are from different set of models, choose the appropriate one using the radio button.

Advanced settings

Advanced settings

  • Use GPU: GPUs enable faster AU predictions. If your machine has a GPU that you wish to use, enable this.
  • Batch size: The batch size for AU predictions. Larger GPUs memory can accommodate higher batch size.
  • Preprocessing batch size: Batch size parameter for all pre-AU prediction operations. A higher batch size would require more RAM but speeds up the pipeline.
  • AU occurrence: Choice of occurrence predictions required from the Input Videos.
  • AU intensity: Choice of intensity predictions required from the Input Videos.

Person Tracking feature setting has been temporarily disabled for dependency conflicts. A future version with a fix would be released.

Python Interface

To use PyAFAR in your Python code import adult_afar or infant_afar and set the above-mentioned flags. An example of adult video and infant video usage are shown below.

# using PyAFAR's adult models
from PyAFAR_GUI.adult_afar import adult_afar
import pandas as pd
# note that PID enables person tracking
adult_result = adult_afar(filename=<insert video>,  AUs=["au_1", "au_2","au_4", "au_6","au_7", "au_10","au_12", "au_14","au_15", "au_17","au_23", "au_24"], GPU=True, max_frames=1000, AU_Int=["au_6", "au_10","au_12", "au_14","au_17"], batch_size=100, PID=False)
adult_df = pd.DataFrame.from_dict(adult_result)

# using PyAFAR's infant models
from PyAFAR_GUI.infant_afar import infant_afar
infant_result = infant_afar(filename=<insert video>, AUs=["au_6", "au_4", "au_12"], GPU=False, max_frames=1000)
infant_df = pd.DataFrame.from_dict(infant_result)

If importing infant_afar gives libstdc++.so version errors, please see the recommendation on how to fix it here.

Clone this wiki locally