You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the python package for `LibreFace: An Open-Source Toolkit for Deep Facial Expression Analysis`_.
20
+
This is the Python package for `LibreFace: An Open-Source Toolkit for Deep Facial Expression Analysis`_.
21
21
LibreFace is an open-source and comprehensive toolkit for accurate and real-time facial expression analysis with both CPU and GPU acceleration versions.
22
22
LibreFace eliminates the gap between cutting-edge research and an easy and free-to-use non-commercial toolbox. We propose to adaptively pre-train the vision encoders with various face datasets and then distill them to a lightweight ResNet-18 model in a feature-wise matching manner.
23
23
We conduct extensive experiments of pre-training and distillation to demonstrate that our proposed pipeline achieves comparable results to state-of-the-art works while maintaining real-time efficiency.
@@ -31,7 +31,7 @@ Dependencies
31
31
32
32
- Python==3.8
33
33
- You should have `cmake` installed in your system.
34
-
- **For Linux users** - :code:`sudo apt-get install cmake`. If you run into troubles, consider upgrading to the latest version (`instructions`_).
34
+
- **For Linux users** - :code:`sudo apt-get install cmake`. If you run into trouble, consider upgrading to the latest version (`instructions`_).
Note that the above script would save results in a CSV at the default location - :code:`sample_results.csv`. If you want to specify your own path, use the :code:`--output_path` commandline argument,
61
+
Note that the above script would save results in a CSV at the default location - :code:`sample_results.csv`. If you want to specify your own path, use the :code:`--output_path` command line argument,
For video inference, our code processes the frames of your video in batches. You can specify the batch size and the number of workers for data loading as follows,
Note that by default, the :code:`--batch_size` argument is 256, and :code:`--num_workers` argument is 2. You can increase or decrease these values according to your machine's capacity.
78
86
79
87
**Examples**
80
88
81
-
Download a `sample image`_ from our github repository. To get the facial attributes for this image and save to a CSV file simply run,
89
+
Download a `sample image`_ from our GitHub repository. To get the facial attributes for this image and save to a CSV file, simply run,
Download a `sample video`_ from our github repository. To run the inference on this video using a GPU and save the results to :code:`my_custom_file.csv` run the following command,
97
+
Download a `sample video`_ from our GitHub repository. To run the inference on this video using a GPU and save the results to :code:`my_custom_file.csv` run the following command,
For video inference, our code processes the frames of your video in batches. You can specify the batch size and the number of workers for data loading as follows,
144
+
145
+
.. code-block:: python
146
+
147
+
import libreface
148
+
libreface.get_facial_attributes(video_path,
149
+
batch_size=256,
150
+
num_workers=2)
151
+
152
+
Note that by default, the :code:`batch_size` is 256, and :code:`num_workers` is 2. You can increase or decrease these values according to your machine's capacity.
134
153
135
154
Downloading Model Weights
136
155
================================
@@ -162,6 +181,11 @@ For an image processed through LibreFace, we save the following information in t
162
181
163
182
For a video, we save the same features for each frame in the video at index :code:`frame_idx` and timestamp :code:`frame_time_in_ms`.
164
183
184
+
Inference Speed
185
+
====================
186
+
187
+
LibreFace is able to process long-form videos at :code:`~30 FPS`, on a machine that has a :code:`13th Gen Intel Core i9-13900K` CPU and a :code:`NVIDIA GeForce RTX 3080` GPU. Please note that the default code runs on CPU and you have to use the :code:`device` parameter for Python or the :code:`--device` command line option to specify your GPU device ("cuda:0", "cuda:1", ...).
Copy file name to clipboardexpand all lines: libreface/commandline.py
+2
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ def main_func():
9
9
parser.add_argument("--output_path", type=str, default="sample_results.csv", help="Path to the csv where results should be saved. Defaults to 'sample_results.csv'")
10
10
parser.add_argument("--device", type=str, default="cpu", help="Device to use while inference. Can be 'cpu', 'cuda:0', 'cuda:1', ... Defaults to 'cpu'")
11
11
parser.add_argument("--temp", type=str, default="./tmp", help="Path where the temporary results for facial attributes can be saved.")
12
+
parser.add_argument("--batch_size", type=int, default=256, help="Number of frames to process in a single batch when doing inference on a video.")
12
13
parser.add_argument("--num_workers", type=int, default=2, help="Number of workers to be used in the dataloader while doing inference on a video.")
0 commit comments