pyfaceau 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. pyfaceau-1.0.3/COMMERCIAL-LICENSE.md +109 -0
  2. pyfaceau-1.0.3/LICENSE +40 -0
  3. pyfaceau-1.0.3/MANIFEST.in +31 -0
  4. pyfaceau-1.0.3/PKG-INFO +466 -0
  5. pyfaceau-1.0.3/README.md +421 -0
  6. pyfaceau-1.0.3/pyfaceau/__init__.py +19 -0
  7. pyfaceau-1.0.3/pyfaceau/alignment/__init__.py +0 -0
  8. pyfaceau-1.0.3/pyfaceau/alignment/calc_params.py +671 -0
  9. pyfaceau-1.0.3/pyfaceau/alignment/face_aligner.py +352 -0
  10. pyfaceau-1.0.3/pyfaceau/alignment/numba_calcparams_accelerator.py +244 -0
  11. pyfaceau-1.0.3/pyfaceau/detectors/__init__.py +0 -0
  12. pyfaceau-1.0.3/pyfaceau/detectors/pfld.py +128 -0
  13. pyfaceau-1.0.3/pyfaceau/detectors/retinaface.py +352 -0
  14. pyfaceau-1.0.3/pyfaceau/download_weights.py +134 -0
  15. pyfaceau-1.0.3/pyfaceau/features/__init__.py +0 -0
  16. pyfaceau-1.0.3/pyfaceau/features/histogram_median_tracker.py +335 -0
  17. pyfaceau-1.0.3/pyfaceau/features/pdm.py +269 -0
  18. pyfaceau-1.0.3/pyfaceau/features/triangulation.py +64 -0
  19. pyfaceau-1.0.3/pyfaceau/parallel_pipeline.py +462 -0
  20. pyfaceau-1.0.3/pyfaceau/pipeline.py +1083 -0
  21. pyfaceau-1.0.3/pyfaceau/prediction/__init__.py +0 -0
  22. pyfaceau-1.0.3/pyfaceau/prediction/au_predictor.py +434 -0
  23. pyfaceau-1.0.3/pyfaceau/prediction/batched_au_predictor.py +269 -0
  24. pyfaceau-1.0.3/pyfaceau/prediction/model_parser.py +337 -0
  25. pyfaceau-1.0.3/pyfaceau/prediction/running_median.py +318 -0
  26. pyfaceau-1.0.3/pyfaceau/prediction/running_median_fallback.py +200 -0
  27. pyfaceau-1.0.3/pyfaceau/processor.py +270 -0
  28. pyfaceau-1.0.3/pyfaceau/refinement/__init__.py +12 -0
  29. pyfaceau-1.0.3/pyfaceau/refinement/svr_patch_expert.py +361 -0
  30. pyfaceau-1.0.3/pyfaceau/refinement/targeted_refiner.py +362 -0
  31. pyfaceau-1.0.3/pyfaceau/utils/__init__.py +0 -0
  32. pyfaceau-1.0.3/pyfaceau/utils/cython_extensions/cython_histogram_median.c +35391 -0
  33. pyfaceau-1.0.3/pyfaceau/utils/cython_extensions/cython_histogram_median.pyx +316 -0
  34. pyfaceau-1.0.3/pyfaceau/utils/cython_extensions/cython_rotation_update.c +32262 -0
  35. pyfaceau-1.0.3/pyfaceau/utils/cython_extensions/cython_rotation_update.pyx +211 -0
  36. pyfaceau-1.0.3/pyfaceau/utils/cython_extensions/setup.py +47 -0
  37. pyfaceau-1.0.3/pyfaceau.egg-info/PKG-INFO +466 -0
  38. pyfaceau-1.0.3/pyfaceau.egg-info/SOURCES.txt +46 -0
  39. pyfaceau-1.0.3/pyfaceau.egg-info/dependency_links.txt +1 -0
  40. pyfaceau-1.0.3/pyfaceau.egg-info/entry_points.txt +3 -0
  41. pyfaceau-1.0.3/pyfaceau.egg-info/not-zip-safe +1 -0
  42. pyfaceau-1.0.3/pyfaceau.egg-info/requires.txt +17 -0
  43. pyfaceau-1.0.3/pyfaceau.egg-info/top_level.txt +1 -0
  44. pyfaceau-1.0.3/pyfaceau_gui.py +302 -0
  45. pyfaceau-1.0.3/pyproject.toml +70 -0
  46. pyfaceau-1.0.3/requirements.txt +6 -0
  47. pyfaceau-1.0.3/setup.cfg +4 -0
  48. pyfaceau-1.0.3/setup.py +110 -0
@@ -0,0 +1,109 @@
1
+ # Commercial License for PyFaceAU
2
+
3
+ ## Overview
4
+
5
+ PyFaceAU is available under a dual licensing model:
6
+
7
+ 1. **Non-Commercial License**: Free for research, education, and personal use under CC BY-NC 4.0
8
+ 2. **Commercial License**: Available for commercial applications (this document)
9
+
10
+ ## When Do You Need a Commercial License?
11
+
12
+ You need a commercial license if you plan to:
13
+
14
+ - Use PyFaceAU in a commercial product or service
15
+ - Provide commercial services using PyFaceAU
16
+ - Use PyFaceAU within a for-profit organization
17
+ - Receive any form of monetary compensation related to your use of PyFaceAU
18
+ - Integrate PyFaceAU into proprietary software
19
+ - Use PyFaceAU for competitive analysis or business intelligence
20
+
21
+ ## Non-Commercial Use (Free)
22
+
23
+ You DO NOT need a commercial license for:
24
+
25
+ - Academic research and publications
26
+ - Educational purposes (teaching, coursework)
27
+ - Personal projects and experimentation
28
+ - Non-profit organization use (charitable, educational, scientific)
29
+ - Open-source projects under compatible licenses
30
+
31
+ ## Commercial License Benefits
32
+
33
+ A commercial license provides:
34
+
35
+ - ✓ Full rights to use PyFaceAU in commercial applications
36
+ - ✓ Right to modify and distribute within your organization
37
+ - ✓ Integration into proprietary products
38
+ - ✓ No attribution requirements in end-user facing materials
39
+ - ✓ Warranty and support options (depending on license tier)
40
+ - ✓ Priority bug fixes and feature requests
41
+ - ✓ Legal protection and indemnification
42
+
43
+ ## License Tiers
44
+
45
+ ### Startup License
46
+ - For companies with < $1M annual revenue
47
+ - Single product use
48
+ - Up to 5 developers
49
+ - Email support
50
+
51
+ ### Professional License
52
+ - For established businesses
53
+ - Unlimited products
54
+ - Unlimited developers within one organization
55
+ - Priority email support
56
+ - SLA guarantees
57
+
58
+ ### Enterprise License
59
+ - For large organizations
60
+ - Multi-subsidiary use
61
+ - Custom terms available
62
+ - Dedicated support channel
63
+ - On-premises deployment options
64
+ - Source code access
65
+
66
+ ## Pricing
67
+
68
+ For current pricing and to request a commercial license quote:
69
+
70
+ **Contact Information:**
71
+ - Email: [Your email address]
72
+ - Website: [Your website/contact form]
73
+ - GitHub: https://github.com/johnwilsoniv/pyfaceau
74
+
75
+ ## Frequently Asked Questions
76
+
77
+ **Q: Can I evaluate PyFaceAU before purchasing a commercial license?**
78
+ A: Yes, you may evaluate PyFaceAU for commercial viability for up to 30 days without a commercial license.
79
+
80
+ **Q: What happens if I need to stop my commercial license?**
81
+ A: You must cease all commercial use of PyFaceAU. Academic/non-commercial use remains available under CC BY-NC 4.0.
82
+
83
+ **Q: Can I get a perpetual license?**
84
+ A: Yes, perpetual licenses are available. Contact us for details.
85
+
86
+ **Q: Is the commercial license per-developer or per-organization?**
87
+ A: Licenses are per-organization (except Startup tier which has developer limits).
88
+
89
+ **Q: Do you offer discounts for startups or small businesses?**
90
+ A: Yes, see our Startup License tier for companies under $1M annual revenue.
91
+
92
+ ## Terms and Conditions
93
+
94
+ Commercial licenses are subject to our standard commercial terms, which include:
95
+
96
+ - License grant and scope
97
+ - Warranty and liability limitations
98
+ - Support and maintenance terms
99
+ - Termination conditions
100
+ - Payment terms
101
+
102
+ Full terms provided upon license purchase.
103
+
104
+ ---
105
+
106
+ **Last Updated:** January 2025
107
+
108
+ For all inquiries regarding commercial licensing, please contact:
109
+ [Your contact information]
pyfaceau-1.0.3/LICENSE ADDED
@@ -0,0 +1,40 @@
1
+ Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
2
+
3
+ Copyright (c) 2025 John Wilson IV, MD
4
+
5
+ This work is licensed under the Creative Commons Attribution-NonCommercial 4.0
6
+ International License. To view a copy of this license, visit:
7
+ https://creativecommons.org/licenses/by-nc/4.0/
8
+
9
+ YOU ARE FREE TO:
10
+ - Share: copy and redistribute the material in any medium or format
11
+ - Adapt: remix, transform, and build upon the material
12
+
13
+ UNDER THE FOLLOWING TERMS:
14
+ - Attribution: You must give appropriate credit, provide a link to the license,
15
+ and indicate if changes were made.
16
+ - NonCommercial: You may not use the material for commercial purposes.
17
+ - No additional restrictions: You may not apply legal terms or technological
18
+ measures that legally restrict others from doing anything the license permits.
19
+
20
+ NOTICES:
21
+ You do not have to comply with the license for elements of the material in the
22
+ public domain or where your use is permitted by an applicable exception or limitation.
23
+
24
+ No warranties are given. The license may not give you all of the permissions
25
+ necessary for your intended use. For example, other rights such as publicity,
26
+ privacy, or moral rights may limit how you use the material.
27
+
28
+ ================================================================================
29
+
30
+ COMMERCIAL LICENSING:
31
+
32
+ If you wish to use pyfaceau for commercial purposes, you must obtain a separate
33
+ commercial license. See COMMERCIAL-LICENSE.md for details or contact:
34
+ [Your contact information - email/website]
35
+
36
+ Commercial use includes, but is not limited to:
37
+ - Use in a commercial product or service
38
+ - Use to provide commercial services
39
+ - Use in a for-profit organization
40
+ - Any use where you or your organization receives monetary compensation
@@ -0,0 +1,31 @@
1
+ # Include documentation and license files
2
+ include README.md
3
+ include LICENSE
4
+ include COMMERCIAL-LICENSE.md
5
+ include requirements.txt
6
+
7
+ # Include Cython source files for building extensions
8
+ recursive-include pyfaceau/utils/cython_extensions *.pyx *.pxd *.c
9
+
10
+ # Include package data files
11
+ recursive-include pyfaceau *.txt *.json
12
+
13
+ # Exclude compiled files and caches
14
+ global-exclude *.pyc
15
+ global-exclude *.pyo
16
+ global-exclude *.so
17
+ global-exclude *.dylib
18
+ global-exclude __pycache__
19
+ global-exclude .DS_Store
20
+
21
+ # Exclude weights (too large for PyPI, users must download separately)
22
+ exclude weights/*
23
+ recursive-exclude weights *
24
+
25
+ # Exclude development files
26
+ exclude .gitignore
27
+ exclude .gitattributes
28
+ recursive-exclude tests *
29
+ recursive-exclude tools *
30
+ recursive-exclude benchmarks *
31
+ recursive-exclude docs *
@@ -0,0 +1,466 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyfaceau
3
+ Version: 1.0.3
4
+ Summary: Pure Python OpenFace 2.2 AU extraction with CLNF landmark refinement
5
+ Home-page: https://github.com/johnwilsoniv/face-analysis
6
+ Author: John Wilson
7
+ Author-email:
8
+ License: CC BY-NC 4.0
9
+ Project-URL: Homepage, https://github.com/johnwilsoniv/face-analysis
10
+ Project-URL: Documentation, https://github.com/johnwilsoniv/face-analysis/tree/main/S0%20PyfaceAU
11
+ Project-URL: Repository, https://github.com/johnwilsoniv/face-analysis
12
+ Project-URL: Bug Tracker, https://github.com/johnwilsoniv/face-analysis/issues
13
+ Keywords: facial-action-units,openface,computer-vision,facial-analysis,emotion-recognition
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
18
+ Classifier: License :: Other/Proprietary License
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: numpy>=1.20.0
28
+ Requires-Dist: opencv-python>=4.5.0
29
+ Requires-Dist: pandas>=1.3.0
30
+ Requires-Dist: onnxruntime>=1.10.0
31
+ Requires-Dist: scipy>=1.7.0
32
+ Requires-Dist: scikit-learn>=1.0.0
33
+ Requires-Dist: tqdm>=4.62.0
34
+ Requires-Dist: pyfhog>=0.1.0
35
+ Requires-Dist: Cython>=0.29.0
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
38
+ Requires-Dist: black>=22.0.0; extra == "dev"
39
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
40
+ Provides-Extra: accel
41
+ Requires-Dist: onnxruntime-coreml>=1.10.0; extra == "accel"
42
+ Dynamic: home-page
43
+ Dynamic: license-file
44
+ Dynamic: requires-python
45
+
46
+ # pyfaceau - Action Unit Generation based on Python and Openface 2.2
47
+
48
+
49
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
50
+ [![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
51
+
52
+ ---
53
+
54
+ ## Overview
55
+
56
+ pyfaceau is a Python reimplementation of the [OpenFace 2.2](https://github.com/TadasBaltrusaitis/OpenFace) Facial Action Unit extraction pipeline. It achieves **r =92 correlation** with the original C++ implementation while requiring **zero compilation** and running on any platform.
57
+
58
+ ### Key Features
59
+
60
+ - ** 100% Python** - No C++ compilation required
61
+ - ** Easy Installation** - `pip install` and go
62
+ - ** High Accuracy** - r=0.92 overall
63
+ - ** High Performance** - 50-100 FPS with parallel processing (6-10x speedup!)
64
+ - ** Multi-Core Support** - Automatic parallelization across CPU cores
65
+ - ** Modular** - Use individual components independently
66
+ - ** 17 Action Units** - Full AU extraction (AU01, AU02, AU04, etc.)
67
+
68
+ ---
69
+
70
+ ## Quick Start
71
+
72
+ ### Installation
73
+
74
+ #### Option 1: Install from PyPI (Recommended)
75
+
76
+ ```bash
77
+ # Install pyfaceau
78
+ pip install pyfaceau
79
+
80
+ # Download model weights (14MB)
81
+ python -m pyfaceau.download_weights
82
+
83
+ # Or manually download from GitHub
84
+ # https://github.com/johnwilsoniv/face-analysis/tree/main/S0%20PyfaceAU/weights
85
+ ```
86
+
87
+ #### Option 2: Install from Source
88
+
89
+ ```bash
90
+ # Clone repository
91
+ git clone https://github.com/johnwilsoniv/face-analysis.git
92
+ cd "face-analysis/S0 PyfaceAU"
93
+
94
+ # Install in development mode
95
+ pip install -e .
96
+
97
+ # Model weights are included in the repository
98
+ ```
99
+
100
+ ### Basic Usage
101
+
102
+ #### High-Performance Mode (Recommended - 50-100 FPS)
103
+
104
+ ```python
105
+ from pyfaceau import ParallelAUPipeline
106
+
107
+ # Initialize parallel pipeline
108
+ pipeline = ParallelAUPipeline(
109
+ retinaface_model='weights/retinaface_mobilenet025_coreml.onnx',
110
+ pfld_model='weights/pfld_cunjian.onnx',
111
+ pdm_file='weights/In-the-wild_aligned_PDM_68.txt',
112
+ au_models_dir='path/to/AU_predictors',
113
+ triangulation_file='weights/tris_68_full.txt',
114
+ num_workers=6, # Adjust based on CPU cores
115
+ batch_size=30
116
+ )
117
+
118
+ # Process video
119
+ results = pipeline.process_video(
120
+ video_path='input.mp4',
121
+ output_csv='results.csv'
122
+ )
123
+
124
+ print(f"Processed {len(results)} frames")
125
+ # Typical output: ~28-50 FPS depending on CPU cores
126
+ ```
127
+
128
+ #### Standard Mode (4.6 FPS)
129
+
130
+ ```python
131
+ from pyfaceau import FullPythonAUPipeline
132
+
133
+ # Initialize standard pipeline
134
+ pipeline = FullPythonAUPipeline(
135
+ retinaface_model='weights/retinaface_mobilenet025_coreml.onnx',
136
+ pfld_model='weights/pfld_cunjian.onnx',
137
+ pdm_file='weights/In-the-wild_aligned_PDM_68.txt',
138
+ au_models_dir='path/to/AU_predictors',
139
+ triangulation_file='weights/tris_68_full.txt',
140
+ use_calc_params=True,
141
+ use_coreml=True, # macOS only
142
+ verbose=False
143
+ )
144
+
145
+ # Process video
146
+ results = pipeline.process_video(
147
+ video_path='input.mp4',
148
+ output_csv='results.csv'
149
+ )
150
+ ```
151
+
152
+ ### Example Output
153
+
154
+ ```csv
155
+ frame,success,AU01_r,AU02_r,AU04_r,AU06_r,AU12_r,...
156
+ 0,True,0.60,0.90,0.00,1.23,2.45,...
157
+ 1,True,0.55,0.85,0.00,1.20,2.50,...
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Architecture
163
+
164
+ pyfaceau replicates the complete OpenFace 2.2 AU extraction pipeline:
165
+
166
+ ```
167
+ Video Input
168
+
169
+ Face Detection (RetinaFace ONNX)
170
+
171
+ Landmark Detection (PFLD 68-point)
172
+
173
+ 3D Pose Estimation (Python Implementation of CalcParams with 98% fidelity)
174
+
175
+ Face Alignment
176
+
177
+ HOG Feature Extraction (PyFHOG)
178
+
179
+ Geometric Features (PDM reconstruction)
180
+
181
+ Running Median Tracking (Cython-optimized)
182
+
183
+ AU Prediction (17 SVR models)
184
+
185
+ Output: 17 AU intensities
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Custom Components & Innovations
191
+
192
+ pyfaceau includes several novel components that can be used independently in other projects:
193
+
194
+ ### Python-based CalcParams - 3D Pose Estimation
195
+
196
+ A pure Python implementation of OpenFace's CalcParams algorithm for 3D head pose estimation. Achieves 99.45% correlation with the C++ reference implementation.
197
+
198
+ ```python
199
+ from pyfaceau.alignment import CalcParams
200
+
201
+ # Initialize with PDM model
202
+ calc_params = CalcParams(pdm_file='weights/In-the-wild_aligned_PDM_68.txt')
203
+
204
+ # Estimate 3D pose from 2D landmarks
205
+ params_local, params_global, detected_landmarks = calc_params.estimate_pose(
206
+ landmarks_2d, # 68x2 array of detected landmarks
207
+ img_width,
208
+ img_height
209
+ )
210
+
211
+ # Extract pose parameters
212
+ tx, ty = params_global[4], params_global[5] # Translation
213
+ rx, ry, rz = params_global[1:4] # Rotation (radians)
214
+ scale = params_global[0] # Scale factor
215
+ ```
216
+
217
+ **Use cases:** Head pose tracking, gaze estimation, facial alignment
218
+
219
+ ### CLNF Landmark Refinement
220
+
221
+ Constrained Local Neural Fields (CLNF) refinement using SVR patch experts for improved landmark accuracy. Particularly effective for challenging poses and expressions.
222
+
223
+ ```python
224
+ from pyfaceau.detectors import CLNFRefiner
225
+
226
+ # Initialize refiner
227
+ refiner = CLNFRefiner(
228
+ pdm_file='weights/In-the-wild_aligned_PDM_68.txt',
229
+ patch_expert_file='weights/svr_patches_0.25_general.txt'
230
+ )
231
+
232
+ # Refine landmarks
233
+ refined_landmarks = refiner.refine_landmarks(
234
+ frame,
235
+ initial_landmarks,
236
+ face_bbox,
237
+ num_iterations=5
238
+ )
239
+ ```
240
+
241
+ **Use cases:** Landmark tracking, facial feature extraction, expression analysis
242
+
243
+ ### Cython Histogram Median Tracker (260x speedup)
244
+
245
+ High-performance running median tracking for temporal smoothing of geometric features. Implements OpenFace's histogram-based median algorithm in optimized Cython.
246
+
247
+ ```python
248
+ from pyfaceau.features import HistogramMedianTracker
249
+
250
+ # Initialize tracker
251
+ tracker = HistogramMedianTracker(
252
+ num_features=136, # 68 landmarks x 2 (x,y)
253
+ history_length=120
254
+ )
255
+
256
+ # Update with new frame
257
+ smoothed_features = tracker.update(current_features)
258
+ ```
259
+
260
+ **Use cases:** Temporal smoothing, noise reduction, video feature tracking
261
+
262
+ ### Batched AU Predictor
263
+
264
+ Optimized AU prediction using batch processing for HOG features. Reduces overhead when processing multiple frames.
265
+
266
+ ```python
267
+ from pyfaceau.prediction import BatchedAUPredictor
268
+
269
+ # Initialize predictor
270
+ predictor = BatchedAUPredictor(
271
+ au_models_dir='weights/AU_predictors',
272
+ batch_size=30
273
+ )
274
+
275
+ # Predict AUs for multiple frames
276
+ au_results = predictor.predict_batch(
277
+ hog_features_list, # List of HOG feature arrays
278
+ geom_features_list # List of geometric feature arrays
279
+ )
280
+ ```
281
+
282
+ **Use cases:** Video processing, batch AU extraction, real-time analysis
283
+
284
+ ### OpenFace22 Face Aligner
285
+
286
+ Pure Python implementation of OpenFace 2.2's face alignment algorithm. Produces pixel-perfect aligned faces matching the C++ implementation.
287
+
288
+ ```python
289
+ from pyfaceau.alignment import OpenFace22FaceAligner
290
+
291
+ # Initialize aligner
292
+ aligner = OpenFace22FaceAligner(
293
+ pdm_file='weights/In-the-wild_aligned_PDM_68.txt',
294
+ triangulation_file='weights/tris_68_full.txt'
295
+ )
296
+
297
+ # Align face for AU extraction
298
+ aligned_face = aligner.align_face(
299
+ frame,
300
+ landmarks_2d,
301
+ tx, ty, rz # From CalcParams
302
+ )
303
+ ```
304
+
305
+ **Output:** 112x112 RGB aligned face, ready for HOG extraction
306
+
307
+ **Use cases:** Face normalization, AU extraction preprocessing, facial feature analysis
308
+
309
+ ---
310
+
311
+ ## Supported Action Units
312
+
313
+ pyfaceau extracts 17 Facial Action Units:
314
+
315
+ **Dynamic AUs (11):**
316
+ - AU01 - Inner Brow Raiser
317
+ - AU02 - Outer Brow Raiser
318
+ - AU05 - Upper Lid Raiser
319
+ - AU09 - Nose Wrinkler
320
+ - AU15 - Lip Corner Depressor
321
+ - AU17 - Chin Raiser
322
+ - AU20 - Lip Stretcher
323
+ - AU23 - Lip Tightener
324
+ - AU25 - Lips Part
325
+ - AU26 - Jaw Drop
326
+ - AU45 - Blink
327
+
328
+ **Static AUs (6):**
329
+ - AU04 - Brow Lowerer
330
+ - AU06 - Cheek Raiser
331
+ - AU07 - Lid Tightener
332
+ - AU10 - Upper Lip Raiser
333
+ - AU12 - Lip Corner Puller
334
+ - AU14 - Dimpler
335
+
336
+ ---
337
+
338
+ ## Requirements
339
+
340
+ ### Python Dependencies
341
+
342
+ ```
343
+ python >= 3.10
344
+ numpy >= 1.20.0
345
+ opencv-python >= 4.5.0
346
+ pandas >= 1.3.0
347
+ scipy >= 1.7.0
348
+ onnxruntime >= 1.10.0
349
+ pyfhog >= 0.1.0
350
+ ```
351
+
352
+ ### Model Files
353
+
354
+ Download OpenFace 2.2 AU predictor models:
355
+ - Available from: [OpenFace repository](https://github.com/TadasBaltrusaitis/OpenFace)
356
+ - Place in: `AU_predictors/` directory
357
+ - Required: 17 `.dat` files (AU_1_dynamic_intensity_comb.dat, etc.)
358
+
359
+ ---
360
+
361
+ ## Project Structure
362
+
363
+ ```
364
+ S0 pyfaceau/
365
+ ├── pyfaceau/ # Core library
366
+ │ ├── pipeline.py # Full AU extraction pipeline
367
+ │ ├── detectors/ # Face and landmark detection
368
+ │ ├── alignment/ # Face alignment and pose estimation
369
+ │ ├── features/ # HOG and geometric features
370
+ │ ├── prediction/ # AU prediction and running median
371
+ │ └── utils/ # Utilities and Cython extensions
372
+ ├── weights/ # Model weights
373
+ ├── tests/ # Test suite
374
+ ├── examples/ # Usage examples
375
+ └── docs/ # Documentation
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Advanced Usage
381
+
382
+ ### Process Single Frame
383
+
384
+ ```python
385
+ from pyfaceau import FullPythonAUPipeline
386
+ import cv2
387
+
388
+ pipeline = FullPythonAUPipeline(...)
389
+
390
+ # Read frame
391
+ frame = cv2.imread('image.jpg')
392
+
393
+ # Process (requires landmarks and pose from CSV or detector)
394
+ aligned = pipeline.aligner.align_face(frame, landmarks, tx, ty, rz)
395
+ hog_features = pipeline.extract_hog(aligned)
396
+ aus = pipeline.predict_aus(hog_features, geom_features)
397
+ ```
398
+
399
+ ### Use Individual Components
400
+
401
+ ```python
402
+ # Face detection only
403
+ from pyfaceau.detectors import ONNXRetinaFaceDetector
404
+ detector = ONNXRetinaFaceDetector('weights/retinaface_mobilenet025_coreml.onnx')
405
+ faces = detector.detect_faces(frame)
406
+
407
+ # Landmark detection only
408
+ from pyfaceau.detectors import CunjianPFLDDetector
409
+ landmarker = CunjianPFLDDetector('weights/pfld_cunjian.onnx')
410
+ landmarks, conf = landmarker.detect_landmarks(frame, bbox)
411
+
412
+ # Face alignment only
413
+ from pyfaceau.alignment import OpenFace22FaceAligner
414
+ aligner = OpenFace22FaceAligner('weights/In-the-wild_aligned_PDM_68.txt')
415
+ aligned = aligner.align_face(frame, landmarks, tx, ty, rz)
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Citation
421
+
422
+ If you use pyfaceau in your research, please cite:
423
+
424
+ ```bibtex
425
+ @article{wilson2025splitface,
426
+ title={A Split-Face Computer Vision/Machine Learning Assessment of Facial Paralysis Using Facial Action Units},
427
+ author={Wilson IV, John and Rosenberg, Joshua and Gray, Mingyang L and Razavi, Christopher R},
428
+ journal={Facial Plastic Surgery \& Aesthetic Medicine},
429
+ year={2025},
430
+ publisher={Mary Ann Liebert, Inc.}
431
+ }
432
+ ```
433
+
434
+ Also cite the original OpenFace:
435
+
436
+ ```bibtex
437
+ @inproceedings{baltrusaitis2018openface,
438
+ title={OpenFace 2.0: Facial behavior analysis toolkit},
439
+ author={Baltru{\v{s}}aitis, Tadas and Zadeh, Amir and Lim, Yao Chong and Morency, Louis-Philippe},
440
+ booktitle={2018 13th IEEE International Conference on Automatic Face \& Gesture Recognition (FG 2018)},
441
+ pages={59--66},
442
+ year={2018},
443
+ organization={IEEE}
444
+ }
445
+ ```
446
+
447
+ ---
448
+
449
+ ## Acknowledgments
450
+
451
+ - **OpenFace** - Original C++ implementation by Tadas Baltrusaitis
452
+ - **PyFHOG** - HOG feature extraction library
453
+ - **RetinaFace** - Face detection model
454
+ - **PFLD** - Landmark detection by Cunjian Chen
455
+
456
+ ---
457
+
458
+ ## Support
459
+
460
+ - **Issues:** https://github.com/yourname/pyfaceau/issues
461
+ - **Documentation:** [docs/](docs/)
462
+ - **Examples:** [examples/](examples/)
463
+
464
+ ---
465
+
466
+ **Built for the facial behavior research community**