fast-face-python 0.1.1__py3-none-any.whl

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.
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: fast-face-python
3
+ Version: 0.1.1
4
+ Summary: Fast and easy face detection using ONNX runtime.
5
+ Author: xMaulana
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: numpy
10
+ Requires-Dist: Pillow
11
+ Requires-Dist: opencv-python
12
+ Requires-Dist: pydantic-settings>=2.15.0
13
+ Provides-Extra: cpu
14
+ Requires-Dist: onnxruntime>=1.24.3; extra == "cpu"
15
+ Provides-Extra: gpu
16
+ Requires-Dist: onnxruntime-gpu<=1.26.1,>=1.24.3; extra == "gpu"
17
+ Requires-Dist: nvidia-cudnn-cu12; extra == "gpu"
18
+ Requires-Dist: nvidia-cublas-cu12; extra == "gpu"
19
+ Requires-Dist: nvidia-cuda-runtime-cu12; extra == "gpu"
20
+ Provides-Extra: openvino
21
+ Requires-Dist: onnxruntime-openvino>=1.24.1; extra == "openvino"
22
+ Provides-Extra: rocm
23
+ Requires-Dist: onnxruntime-rocm>=1.22.1; extra == "rocm"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Requires-Dist: ruff; extra == "dev"
27
+ Requires-Dist: build; extra == "dev"
28
+ Requires-Dist: twine; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # fast-face-python
32
+
33
+ Fast and easy face detection using ONNX runtime.
34
+
35
+ ## Overview
36
+
37
+ fast-face-python provides a unified interface for running face detection and recognition models using ONNX Runtime. It handles model downloading, preprocessing, inference, and post-processing, including non-maximum suppression for detection and alignment for recognition.
38
+
39
+ The library supports batched inference and configurable execution providers such as CPU, CUDA, ROCm (AMD GPU), and OpenVINO.
40
+
41
+ ## Features
42
+
43
+ * Face Detection: YuNet, RetinaFace (MobileNet, ResNet50)
44
+ * Face Recognition: AdaFace (IR18, IR50, IR101)
45
+ * Hardware Acceleration: CPU, CUDA, ROCm (AMD GPU), and OpenVINO support via ONNX Runtime
46
+ * Batched Inference: Process multiple images simultaneously
47
+ * Automatic Model Management: Downloads required ONNX model weights on first use
48
+
49
+ ## Requirements
50
+
51
+ * Python >= 3.11
52
+ * OpenCV
53
+ * NumPy
54
+ * Pillow
55
+ * ONNX Runtime
56
+
57
+ ## Installation
58
+
59
+ Install the package using pip:
60
+
61
+ ```bash
62
+ pip install fast-face-python
63
+ ```
64
+
65
+ For NVIDIA GPU support via CUDA 12:
66
+
67
+ ```bash
68
+ pip install "fast-face-python[gpu]"
69
+ ```
70
+
71
+ For AMD GPU support via ROCm:
72
+
73
+ ```bash
74
+ pip install "fast-face-python[rocm]"
75
+ ```
76
+
77
+ For OpenVINO support:
78
+
79
+ ```bash
80
+ pip install "fast-face-python[openvino]"
81
+ ```
82
+
83
+ ## Usage
84
+
85
+ ### Face Detection
86
+
87
+ Instantiate a detection model using `FaceModelFactory` and call the `detect` method. The method accepts an image path, a NumPy array in RGB format, or a list of either.
88
+
89
+ ```python
90
+ from fast_face import FaceModelFactory
91
+
92
+ # Initialize the model (weights are downloaded automatically if missing)
93
+ model = FaceModelFactory.get_model("YUNET", top_k=500, conf_threshold=0.6)
94
+
95
+ # Run detection on a local image file
96
+ results = model.detect("image.jpg", return_dict=True)
97
+
98
+ # Process the detections for the first image
99
+ for det in results[0]:
100
+ bbox = det["bbox"]
101
+ confidence = det["score"]
102
+ landmarks = det["landmarks"]
103
+ print(f"Face detected at {bbox} with confidence {confidence}")
104
+ ```
105
+
106
+ To run inference on an existing OpenCV image, convert it to RGB first:
107
+
108
+ ```python
109
+ import cv2
110
+
111
+ img = cv2.imread("image.jpg")
112
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
113
+
114
+ results = model.detect(img_rgb, return_dict=True)
115
+ ```
116
+
117
+ ### Face Recognition
118
+
119
+ Recognition models extract L2-normalized embeddings from aligned face images.
120
+
121
+ ```python
122
+ import numpy as np
123
+ from fast_face import FaceModelFactory
124
+
125
+ model = FaceModelFactory.get_model("ADAFACE_IR50")
126
+
127
+ # Provide pre-aligned 112x112 RGB face crops
128
+ face_crop1 = np.random.randint(0, 255, (112, 112, 3), dtype=np.uint8)
129
+ face_crop2 = np.random.randint(0, 255, (112, 112, 3), dtype=np.uint8)
130
+
131
+ # Extract embeddings for the batch
132
+ embeddings = model.extract([face_crop1, face_crop2])
133
+
134
+ print(f"Extracted {embeddings.shape[0]} embeddings of dimension {embeddings.shape[1]}")
135
+ ```
136
+
137
+ If you have unaligned images and face landmarks from a detection model, you can pass the landmarks to automatically align the faces before extraction:
138
+
139
+ ```python
140
+ landmarks = np.array([
141
+ [200.0, 200.0], [280.0, 200.0], [240.0, 250.0],
142
+ [210.0, 300.0], [270.0, 300.0]
143
+ ], dtype=np.float32)
144
+
145
+ embeddings = model.extract([img_rgb], landmarks=[landmarks])
146
+ ```
147
+
148
+ ### Execution Providers (Hardware Acceleration)
149
+
150
+ By default, all models run using CPU (`["CPUExecutionProvider"]`). You can enable hardware acceleration (CUDA, ROCm, OpenVINO, CoreML, etc.) by passing the `providers` argument to `FaceModelFactory.get_model()`:
151
+
152
+ #### NVIDIA GPU (CUDA)
153
+
154
+ ```python
155
+ model = FaceModelFactory.get_model(
156
+ "RETINAFACE_RESNET50",
157
+ providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
158
+ )
159
+ ```
160
+
161
+ #### AMD GPU (ROCm)
162
+
163
+ ```python
164
+ model = FaceModelFactory.get_model(
165
+ "ADAFACE_IR101",
166
+ providers=["ROCMExecutionProvider", "CPUExecutionProvider"],
167
+ )
168
+ ```
169
+
170
+ #### Intel OpenVINO
171
+
172
+ ```python
173
+ model = FaceModelFactory.get_model(
174
+ "YUNET",
175
+ providers=["OpenVINOExecutionProvider", "CPUExecutionProvider"],
176
+ )
177
+ ```
178
+
179
+ #### Custom Provider Options
180
+
181
+ You can also pass tuple configurations with custom options (such as device ID or memory limits):
182
+
183
+ ```python
184
+ cuda_provider = (
185
+ "CUDAExecutionProvider",
186
+ {
187
+ "device_id": 0,
188
+ "arena_extend_strategy": "kNextPowerOfTwo",
189
+ "gpu_mem_limit": 2 * 1024 * 1024 * 1024, # 2 GB
190
+ },
191
+ )
192
+
193
+ model = FaceModelFactory.get_model(
194
+ "RETINAFACE_RESNET50",
195
+ providers=[cuda_provider, "CPUExecutionProvider"],
196
+ )
197
+ ```
198
+
199
+ ### Supported Models
200
+
201
+ The following model identifiers are supported by `FaceModelFactory`:
202
+
203
+ * `YUNET`
204
+ * `RETINAFACE_MOBILENET`
205
+ * `RETINAFACE_RESNET50`
206
+ * `ADAFACE_IR18`
207
+ * `ADAFACE_IR50`
208
+ * `ADAFACE_IR101`
209
+
210
+ ## Development
211
+
212
+ To set up the repository for development, install the `dev` dependencies:
213
+
214
+ ```bash
215
+ pip install -e ".[dev,cpu]"
216
+ ```
217
+
218
+ ### Testing
219
+
220
+ The project uses `pytest` for testing. Run the test suite:
221
+
222
+ ```bash
223
+ pytest tests/
224
+ ```
225
+
226
+ ### Formatting and Linting
227
+
228
+ The project uses `ruff` for code formatting and linting:
229
+
230
+ ```bash
231
+ ruff check .
232
+ ruff format .
233
+ ```
234
+
235
+ ## License
236
+
237
+ This project is licensed under the terms found in the `LICENSE` file.
@@ -0,0 +1,17 @@
1
+ fast_face/__init__.py,sha256=4jstCjUQOzX_VmxPEfoMSWkj8t3lr_lC9Ce51at1IcI,221
2
+ fast_face/schema.py,sha256=mz8e1en0HJFDFd3B82YU_dVIFum4PuEcThvb2fG4VAU,401
3
+ fast_face/tools.py,sha256=-XTJiPOdhDf2iiSdgT74lsOLYfRDkPw_S_8sz6KAU-U,16613
4
+ fast_face/models/__init__.py,sha256=AC0EpzqkIOKPD7BX9TUCkCgtsBpEAC0GAmY7szWaf9c,220
5
+ fast_face/models/adaface.py,sha256=OKhDArjCD9SxZrbM7gLkQbvDNf1lGMX_TEb5obkQguc,2916
6
+ fast_face/models/base.py,sha256=MS2LvYDsimsiJ_Vjp0bXAnK7HewzUqX7Dxmfr3HWIfQ,3502
7
+ fast_face/models/base_recognition.py,sha256=ZdxrFRvEXJZkGPRXSrJM-awVlGVcH7-gYqOW2kVewXA,1340
8
+ fast_face/models/downloader.py,sha256=w9zwwoC4Qk2sYDOeZMbhqNfce-SJR4J84jah29g-LXI,1501
9
+ fast_face/models/factory.py,sha256=R0aOtDfwfJbS-_a4L3ZNJVBEJ819EqE1f2HGZ6hIv7E,2327
10
+ fast_face/models/retinaface.py,sha256=3mWu-ga6iSsUdoUl_PJZOdqhzQsRJpb7J2_STPCZZ7k,3732
11
+ fast_face/models/session.py,sha256=eH6K8vGO-gy0HhCWyEuWXcHjLU-hOaaR5Kxt3kiL5NA,820
12
+ fast_face/models/yunet.py,sha256=aneo0Xbse7cNdsT5vHQ9siFOZ7oZmk9UJA32l7VTXPs,6567
13
+ fast_face_python-0.1.1.dist-info/licenses/LICENSE,sha256=_sWPoWQ20WP_VJ6Da3HteLJLRBTCt_asLWcxees0Qaw,1065
14
+ fast_face_python-0.1.1.dist-info/METADATA,sha256=G1ydgRB31Gd9JR5e0x9xiAhvYPbWBKIoZZ1fHM2yFjk,5994
15
+ fast_face_python-0.1.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
+ fast_face_python-0.1.1.dist-info/top_level.txt,sha256=4GqYF_q-hFBc2di56LgAgGHlrSrkAbEChw9phg_utNE,10
17
+ fast_face_python-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xMaulana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ fast_face