InspireFace Python API
InspireFace provides an easy-to-use Python API that wraps the underlying dynamic link library through ctypes. You can install the latest release version via pip or configure it using the project's self-compiled dynamic library.
Quick Installation
Install via pip (Recommended)
pip install inspireface
Manual Installation
- Copy the compiled dynamic library to the specified directory:
# Copy the compiled dynamic library to the corresponding system architecture directory
cp YOUR_BUILD_DIR/libInspireFace.so inspireface/modules/core/SYSTEM/CORE_ARCH/
- Install the Python package and its declared dependencies:
pip install .
Quick Start
Here's a simple example showing how to use InspireFace for face detection and landmark drawing:
import cv2
import inspireface as isf
isf.launch()
try:
with isf.InspireFaceSession(
param=isf.HF_ENABLE_NONE,
detect_mode=isf.HF_DETECT_MODE_ALWAYS_DETECT,
auto_launch=False,
) as session:
session.set_detection_confidence_threshold(0.5)
image = cv2.imread("path/to/your/image.jpg")
if image is None:
raise FileNotFoundError("Unable to read the input image")
faces = session.face_detection(image)
print(f"Detected {len(faces)} faces")
draw = image.copy()
for face in faces:
x1, y1, x2, y2 = face.location
center = ((x1 + x2) / 2, (y1 + y2) / 2)
size = (x2 - x1, y2 - y1)
rect = (center, size, face.roll)
box = cv2.boxPoints(rect).astype(int)
cv2.drawContours(draw, [box], 0, (100, 180, 29), 2)
landmarks = session.get_face_dense_landmark(face)
for x, y in landmarks.astype(int):
cv2.circle(draw, (x, y), 0, (220, 100, 0), 2)
finally:
if isf.query_launch_status():
isf.terminate()
More Examples
The project provides multiple example files demonstrating different features:
sample_face_detection.py: Basic face detectionsample_face_track_from_video.py: Video face trackingsample_face_recognition.py: Face recognitionsample_face_comparison.py: Face comparisonsample_feature_hub.py: Feature extractionsample_system_resource_statistics.py: System resource statistics
Running Tests
The comprehensive Python suite shares the same test_res fixture tree as the C++ API tests:
python -m sample_testcase.run --native-lib ../build/lib/libInspireFace.so
Notes
- Ensure that OpenCV and other necessary dependencies are installed on your system
- Make sure the dynamic library is correctly installed before use
- Python 3.7 or higher is recommended
- The default version is CPU, if you want to use the GPU, CoreML, or NPU backend version, you can refer to the documentation to replace the so and make a Python installation package
Metadata
Release files for inspireface 1.2.4.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| inspireface-1.2.4.post1-py3-none-manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| inspireface-1.2.4.post1-py3-none-manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| inspireface-1.2.4.post1-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details |
| inspireface-1.2.4.post1-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Total release size: 11.3 MB
Release files / inspireface-1.2.4.post1-py3-none-manylinux2014_x86_64.whl
| Download URL | inspireface-1.2.4.post1-py3-none-manylinux2014_x86_64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
a03abdb00e720b1b28d3396e58a7efaa7d53a27495907b4a5b08a41060bc4998
|
|
BLAKE2b-256 checksum How to use checksums |
893f42bda9a56dcdf12a497300b303a1a395c4bd89b601ba993b1f6713381474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / inspireface-1.2.4.post1-py3-none-manylinux2014_aarch64.whl
| Download URL | inspireface-1.2.4.post1-py3-none-manylinux2014_aarch64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
1bf302ece3de2ce7bad3a57d8f4018db620b5e6708683c94a70c8fb4865fc4cb
|
|
BLAKE2b-256 checksum How to use checksums |
9a6a64508b3140e7598dfeb89c8bd5f2ea935f6fc04d067616a33bcba634be6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / inspireface-1.2.4.post1-py3-none-macosx_12_0_x86_64.whl
| Download URL | inspireface-1.2.4.post1-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
b3a170d7e76b4db80a28d916c8db64703b4bea1a453febcf9b8f62258f2ca943
|
|
BLAKE2b-256 checksum How to use checksums |
934f42566ac0bfb50a5cdf824f49c8460ff01542b9f29f198d386e4d61f44c6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / inspireface-1.2.4.post1-py3-none-macosx_11_0_arm64.whl
| Download URL | inspireface-1.2.4.post1-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
eb05ea50528975259a51574e03fa6306e24388880f62894bbd3449f7ba21b8ca
|
|
BLAKE2b-256 checksum How to use checksums |
33470d335467acad4f9aeba3a904e4a93491a257768710c3e4d981c6e632861f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|