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
Python 3.7 automatically selects modelscope<1.22.1, and Python 3.8 selects
modelscope<1.29.2. Those newer ModelScope releases require Python 3.8 syntax
and Python 3.9's zoneinfo, respectively, without declaring the minimum in
their package metadata. Python 3.9 and newer keep the normal ModelScope
dependency selection. These compatibility constraints apply on all supported
operating systems.
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.post3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| inspireface-1.2.4.post3-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for inspireface-1.2.4.post3-py3-none-win_amd64.whl |
| inspireface-1.2.4.post3-py3-none-manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details for inspireface-1.2.4.post3-py3-none-manylinux2014_x86_64.whl |
| inspireface-1.2.4.post3-py3-none-manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details for inspireface-1.2.4.post3-py3-none-manylinux2014_aarch64.whl |
| inspireface-1.2.4.post3-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details for inspireface-1.2.4.post3-py3-none-macosx_12_0_x86_64.whl |
| inspireface-1.2.4.post3-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for inspireface-1.2.4.post3-py3-none-macosx_11_0_arm64.whl |
Total release size: 13.7 MB
Release files / inspireface-1.2.4.post3-py3-none-win_amd64.whl
| Download URL | inspireface-1.2.4.post3-py3-none-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c88b3464737005c4b4bde70e7dfdb68ca250d1777f6fe7dde4ab8179e8df6595
|
|
BLAKE2b-256 checksum How to use checksums |
4d7723085149989718e4dc1c3b338e5f6a6e8b459b6a642effb141d12da156e3
|
| 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.post3-py3-none-manylinux2014_x86_64.whl
| Download URL | inspireface-1.2.4.post3-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 |
198547a6e5b647396fabd5389acc0498c33ee4e3aa412199224bd685c0f4cd79
|
|
BLAKE2b-256 checksum How to use checksums |
2c9d6f5d36812db4ed85b974053f3110eb3eb920a528b0d95d946647fee4f24a
|
| 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.post3-py3-none-manylinux2014_aarch64.whl
| Download URL | inspireface-1.2.4.post3-py3-none-manylinux2014_aarch64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
86343a0b51fd62958a0b6f30e8ac568924bda9bdee7ea93520758d4530d814be
|
|
BLAKE2b-256 checksum How to use checksums |
58c29f4b5bf98ca743f520c1f620c269ed82a3db85d56c3db541ec86d4d9240c
|
| 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.post3-py3-none-macosx_12_0_x86_64.whl
| Download URL | inspireface-1.2.4.post3-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 |
3e28d2c4345d884ef3c2e74ff293f5c239c1a1d80b0b3495dcf599d4a0111272
|
|
BLAKE2b-256 checksum How to use checksums |
bc89e7cb0a0754eca23a9e9fc4e2b6fa05e6c9dfcce2482a516b37a451b4fb24
|
| 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.post3-py3-none-macosx_11_0_arm64.whl
| Download URL | inspireface-1.2.4.post3-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 |
edff1f5b7a86ccdc77566d341070b2597b0375140c49df7f73595394da36691b
|
|
BLAKE2b-256 checksum How to use checksums |
68f491db3de3d26759666b2dc90503539f1884f5c96951e0adceb9457c4bddb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for inspireface 1.2.4.post3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.