face-engine 2.1.0__tar.gz → 3.1.0__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 (37) hide show
  1. face_engine-3.1.0/PKG-INFO +171 -0
  2. face_engine-3.1.0/README.rst +132 -0
  3. face_engine-3.1.0/docs/source/conf.py +61 -0
  4. face_engine-3.1.0/face_engine/__init__.py +16 -0
  5. face_engine-3.1.0/face_engine/core.py +500 -0
  6. face_engine-3.1.0/face_engine/fetching.py +145 -0
  7. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine/models/__init__.py +30 -6
  8. face_engine-3.1.0/face_engine/models/_onnx.py +19 -0
  9. face_engine-3.1.0/face_engine/models/basic_estimator.py +68 -0
  10. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine/models/dlib_models.py +40 -28
  11. face_engine-3.1.0/face_engine/models/insightface_models.py +130 -0
  12. face_engine-3.1.0/face_engine/models/minifasnet.py +127 -0
  13. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine/tools.py +26 -12
  14. face_engine-3.1.0/face_engine.egg-info/PKG-INFO +171 -0
  15. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine.egg-info/SOURCES.txt +9 -2
  16. face_engine-3.1.0/face_engine.egg-info/requires.txt +19 -0
  17. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine.egg-info/top_level.txt +2 -0
  18. face_engine-3.1.0/pyproject.toml +67 -0
  19. face_engine-3.1.0/tests/test_face_engine.py +315 -0
  20. face_engine-3.1.0/tests/test_face_engine_models.py +241 -0
  21. face_engine-3.1.0/tests/test_face_engine_persistence.py +126 -0
  22. face_engine-3.1.0/tests/test_fetching.py +87 -0
  23. face-engine-2.1.0/PKG-INFO +0 -88
  24. face-engine-2.1.0/README.rst +0 -61
  25. face-engine-2.1.0/face_engine/__init__.py +0 -18
  26. face-engine-2.1.0/face_engine/core.py +0 -387
  27. face-engine-2.1.0/face_engine/fetching.py +0 -94
  28. face-engine-2.1.0/face_engine/models/basic_estimator.py +0 -48
  29. face-engine-2.1.0/face_engine/models/insightface_models.py +0 -53
  30. face-engine-2.1.0/face_engine.egg-info/PKG-INFO +0 -88
  31. face-engine-2.1.0/face_engine.egg-info/requires.txt +0 -9
  32. face-engine-2.1.0/setup.py +0 -57
  33. {face-engine-2.1.0 → face_engine-3.1.0}/LICENSE +0 -0
  34. {face-engine-2.1.0 → face_engine-3.1.0}/MANIFEST.in +0 -0
  35. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine/exceptions.py +0 -0
  36. {face-engine-2.1.0 → face_engine-3.1.0}/face_engine.egg-info/dependency_links.txt +0 -0
  37. {face-engine-2.1.0 → face_engine-3.1.0}/setup.cfg +0 -0
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: face-engine
3
+ Version: 3.1.0
4
+ Summary: Face Recognition Engine
5
+ Author-email: Daniyar Kussainov <ohw0sseug@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/guesswh0/face_engine
8
+ Classifier: Natural Language :: English
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Education
11
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy<3,>=1.26
23
+ Requires-Dist: pillow>=12.2
24
+ Requires-Dist: tqdm<5,>=4.66.3
25
+ Requires-Dist: platformdirs>=4
26
+ Provides-Extra: insightface
27
+ Requires-Dist: insightface>=1.0.1; extra == "insightface"
28
+ Requires-Dist: onnxruntime>=1.19; extra == "insightface"
29
+ Provides-Extra: dlib
30
+ Requires-Dist: dlib>=19.24; extra == "dlib"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest; extra == "dev"
33
+ Requires-Dist: ruff; extra == "dev"
34
+ Requires-Dist: black; extra == "dev"
35
+ Requires-Dist: sphinx; extra == "dev"
36
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
37
+ Requires-Dist: face-engine[insightface]; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ FaceEngine
41
+ ==========
42
+
43
+ FaceEngine is a lightweight python library that provides an easy interface to
44
+ work with **face recognition** tasks.
45
+
46
+ .. code-block:: python
47
+
48
+ >>> from face_engine import FaceEngine
49
+ >>> engine = FaceEngine()
50
+ >>> engine.fit(['bubbles1.jpg', 'drive.jpg'], [1, 2])
51
+ >>> engine.make_prediction('bubbles2.jpg')
52
+ ([(270, 75, 406, 211)], [1])
53
+
54
+
55
+ Installation
56
+ ------------
57
+
58
+ It is distributed on `PyPi`_, and can be installed with pip:
59
+
60
+ .. code-block:: console
61
+
62
+ $ pip install face-engine[insightface]
63
+
64
+ FaceEngine is supported only on Python 3.11 and above.
65
+
66
+ .. _PyPi: https://pypi.org/project/face-engine/
67
+
68
+ Models
69
+ ------
70
+
71
+ FaceEngine is built on top of four model interfaces ``Detector``, ``Embedder``,
72
+ ``Estimator`` and ``Antispoof`` (see `models`_), and leans on user provided
73
+ implementations of these models.
74
+
75
+ The default backend is `insightface`_ (the ``[insightface]`` extra), with
76
+ these bundled model implementations:
77
+
78
+ ======================= ========== ============ ==========================
79
+ name role model pack notes
80
+ ======================= ========== ============ ==========================
81
+ ``scrfd`` detector buffalo_l default; deprecated alias
82
+ ``retina_face``
83
+ ``arcface`` embedder buffalo_l default, 512-d
84
+ ``scrfd_antelopev2`` detector antelopev2 opt-in
85
+ ``arcface_antelopev2`` embedder antelopev2 strongest insightface
86
+ embedder, 512-d
87
+ ``minifasnet`` antispoof -- passive anti-spoofing,
88
+ opt-in
89
+ ======================= ========== ============ ==========================
90
+
91
+ .. note::
92
+ The ``[insightface]`` extra installs the CPU build of onnxruntime.
93
+ For NVIDIA GPU inference replace it with the GPU build — both
94
+ packages provide the same ``onnxruntime`` module, so the CPU build
95
+ must be removed first::
96
+
97
+ pip uninstall onnxruntime && pip install onnxruntime-gpu
98
+
99
+ The models use the CUDA execution provider automatically when
100
+ available.
101
+
102
+ Legacy `dlib python api`_ models (``hog``, ``mmod`` detectors and ``resnet``
103
+ embedder with dlib pre-trained model `files`_) are kept as an optional
104
+ fallback backend used when insightface is not installed.
105
+
106
+ .. note::
107
+ FaceEngine installation is not installing dlib by default.
108
+ To install it, either run ``pip install dlib`` (requires cmake),
109
+ install prebuilt wheels with ``pip install dlib-bin``, or follow
110
+ `build instructions`_.
111
+
112
+ To work with your own custom models you have to implement required
113
+ `models`_ and import it. FaceEngine models are used to register all inheriting
114
+ imported subclasses (subclass registration `PEP 487`_).
115
+
116
+ Face anti-spoofing
117
+ ------------------
118
+
119
+ Since 3.1 the engine has an opt-in liveness (presentation attack detection)
120
+ step powered by the ``Antispoof`` model interface:
121
+
122
+ .. code-block:: python
123
+
124
+ >>> engine = FaceEngine(antispoof="minifasnet")
125
+ >>> engine.check_liveness('bubbles1.jpg')
126
+ array([0.971], dtype=float32)
127
+
128
+ The bundled ``minifasnet`` model is an ensemble of the two released
129
+ `Silent-Face-Anti-Spoofing`_ MiniFASNet models (requires ``onnxruntime``,
130
+ already present with the ``[insightface]`` extra). It is effective against
131
+ printed photos and basic screen replays; it is **not** a certified
132
+ (ISO/IEC 30107-3) liveness solution.
133
+
134
+ Model weights licensing
135
+ -----------------------
136
+
137
+ The library code is Apache-2.0, but the downloaded pre-trained model weights
138
+ come with their own terms:
139
+
140
+ * insightface model packs (``buffalo_l``, ``antelopev2``) are available for
141
+ **non-commercial research purposes only** (see `insightface`_).
142
+ * dlib model files have their own terms, see `dlib-models`_.
143
+ * ``minifasnet`` model weights are **Apache-2.0** (usable commercially) —
144
+ ONNX exports of the `Silent-Face-Anti-Spoofing`_ checkpoints, reproducible
145
+ with ``extra/export_minifasnet.py``.
146
+
147
+ Breaking changes in 3.0
148
+ -----------------------
149
+
150
+ * Python >= 3.11 is required.
151
+ * Pickle persistence was removed for security reasons: engines are saved as
152
+ JSON (``engine.save('engine.json')``) and estimator state as ``.npz`` +
153
+ ``.json`` files. Engines saved with face-engine < 3.0 cannot be loaded —
154
+ re-fit and save again.
155
+ * With insightface installed the default models are ``scrfd``/``arcface``
156
+ (previously dlib ``hog``/``resnet``).
157
+ * The ``retina_face`` detector was renamed to ``scrfd`` (the actual model
158
+ architecture); the old name is kept as a deprecated alias.
159
+ * Model downloads are verified against pinned SHA-256 checksums.
160
+
161
+ For more information read the full `documentation`_.
162
+
163
+ .. _models: https://github.com/guesswh0/face_engine/blob/master/face_engine/models/__init__.py
164
+ .. _insightface: https://github.com/deepinsight/insightface
165
+ .. _Silent-Face-Anti-Spoofing: https://github.com/minivision-ai/Silent-Face-Anti-Spoofing
166
+ .. _dlib python api: http://dlib.net/python/index.html
167
+ .. _files: https://github.com/davisking/dlib-models
168
+ .. _dlib-models: https://github.com/davisking/dlib-models
169
+ .. _build instructions: http://dlib.net/compile.html
170
+ .. _PEP 487: https://www.python.org/dev/peps/pep-0487/
171
+ .. _documentation: https://face-engine.readthedocs.io/en/latest/
@@ -0,0 +1,132 @@
1
+ FaceEngine
2
+ ==========
3
+
4
+ FaceEngine is a lightweight python library that provides an easy interface to
5
+ work with **face recognition** tasks.
6
+
7
+ .. code-block:: python
8
+
9
+ >>> from face_engine import FaceEngine
10
+ >>> engine = FaceEngine()
11
+ >>> engine.fit(['bubbles1.jpg', 'drive.jpg'], [1, 2])
12
+ >>> engine.make_prediction('bubbles2.jpg')
13
+ ([(270, 75, 406, 211)], [1])
14
+
15
+
16
+ Installation
17
+ ------------
18
+
19
+ It is distributed on `PyPi`_, and can be installed with pip:
20
+
21
+ .. code-block:: console
22
+
23
+ $ pip install face-engine[insightface]
24
+
25
+ FaceEngine is supported only on Python 3.11 and above.
26
+
27
+ .. _PyPi: https://pypi.org/project/face-engine/
28
+
29
+ Models
30
+ ------
31
+
32
+ FaceEngine is built on top of four model interfaces ``Detector``, ``Embedder``,
33
+ ``Estimator`` and ``Antispoof`` (see `models`_), and leans on user provided
34
+ implementations of these models.
35
+
36
+ The default backend is `insightface`_ (the ``[insightface]`` extra), with
37
+ these bundled model implementations:
38
+
39
+ ======================= ========== ============ ==========================
40
+ name role model pack notes
41
+ ======================= ========== ============ ==========================
42
+ ``scrfd`` detector buffalo_l default; deprecated alias
43
+ ``retina_face``
44
+ ``arcface`` embedder buffalo_l default, 512-d
45
+ ``scrfd_antelopev2`` detector antelopev2 opt-in
46
+ ``arcface_antelopev2`` embedder antelopev2 strongest insightface
47
+ embedder, 512-d
48
+ ``minifasnet`` antispoof -- passive anti-spoofing,
49
+ opt-in
50
+ ======================= ========== ============ ==========================
51
+
52
+ .. note::
53
+ The ``[insightface]`` extra installs the CPU build of onnxruntime.
54
+ For NVIDIA GPU inference replace it with the GPU build — both
55
+ packages provide the same ``onnxruntime`` module, so the CPU build
56
+ must be removed first::
57
+
58
+ pip uninstall onnxruntime && pip install onnxruntime-gpu
59
+
60
+ The models use the CUDA execution provider automatically when
61
+ available.
62
+
63
+ Legacy `dlib python api`_ models (``hog``, ``mmod`` detectors and ``resnet``
64
+ embedder with dlib pre-trained model `files`_) are kept as an optional
65
+ fallback backend used when insightface is not installed.
66
+
67
+ .. note::
68
+ FaceEngine installation is not installing dlib by default.
69
+ To install it, either run ``pip install dlib`` (requires cmake),
70
+ install prebuilt wheels with ``pip install dlib-bin``, or follow
71
+ `build instructions`_.
72
+
73
+ To work with your own custom models you have to implement required
74
+ `models`_ and import it. FaceEngine models are used to register all inheriting
75
+ imported subclasses (subclass registration `PEP 487`_).
76
+
77
+ Face anti-spoofing
78
+ ------------------
79
+
80
+ Since 3.1 the engine has an opt-in liveness (presentation attack detection)
81
+ step powered by the ``Antispoof`` model interface:
82
+
83
+ .. code-block:: python
84
+
85
+ >>> engine = FaceEngine(antispoof="minifasnet")
86
+ >>> engine.check_liveness('bubbles1.jpg')
87
+ array([0.971], dtype=float32)
88
+
89
+ The bundled ``minifasnet`` model is an ensemble of the two released
90
+ `Silent-Face-Anti-Spoofing`_ MiniFASNet models (requires ``onnxruntime``,
91
+ already present with the ``[insightface]`` extra). It is effective against
92
+ printed photos and basic screen replays; it is **not** a certified
93
+ (ISO/IEC 30107-3) liveness solution.
94
+
95
+ Model weights licensing
96
+ -----------------------
97
+
98
+ The library code is Apache-2.0, but the downloaded pre-trained model weights
99
+ come with their own terms:
100
+
101
+ * insightface model packs (``buffalo_l``, ``antelopev2``) are available for
102
+ **non-commercial research purposes only** (see `insightface`_).
103
+ * dlib model files have their own terms, see `dlib-models`_.
104
+ * ``minifasnet`` model weights are **Apache-2.0** (usable commercially) —
105
+ ONNX exports of the `Silent-Face-Anti-Spoofing`_ checkpoints, reproducible
106
+ with ``extra/export_minifasnet.py``.
107
+
108
+ Breaking changes in 3.0
109
+ -----------------------
110
+
111
+ * Python >= 3.11 is required.
112
+ * Pickle persistence was removed for security reasons: engines are saved as
113
+ JSON (``engine.save('engine.json')``) and estimator state as ``.npz`` +
114
+ ``.json`` files. Engines saved with face-engine < 3.0 cannot be loaded —
115
+ re-fit and save again.
116
+ * With insightface installed the default models are ``scrfd``/``arcface``
117
+ (previously dlib ``hog``/``resnet``).
118
+ * The ``retina_face`` detector was renamed to ``scrfd`` (the actual model
119
+ architecture); the old name is kept as a deprecated alias.
120
+ * Model downloads are verified against pinned SHA-256 checksums.
121
+
122
+ For more information read the full `documentation`_.
123
+
124
+ .. _models: https://github.com/guesswh0/face_engine/blob/master/face_engine/models/__init__.py
125
+ .. _insightface: https://github.com/deepinsight/insightface
126
+ .. _Silent-Face-Anti-Spoofing: https://github.com/minivision-ai/Silent-Face-Anti-Spoofing
127
+ .. _dlib python api: http://dlib.net/python/index.html
128
+ .. _files: https://github.com/davisking/dlib-models
129
+ .. _dlib-models: https://github.com/davisking/dlib-models
130
+ .. _build instructions: http://dlib.net/compile.html
131
+ .. _PEP 487: https://www.python.org/dev/peps/pep-0487/
132
+ .. _documentation: https://face-engine.readthedocs.io/en/latest/
@@ -0,0 +1,61 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # This file only contains a selection of the most common options. For a full
4
+ # list see the documentation:
5
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
+
7
+ import os
8
+ import sys
9
+
10
+ # -- Path setup --------------------------------------------------------------
11
+
12
+ # If extensions (or modules to document with autodoc) are in another directory,
13
+ # add these directories to sys.path here. If the directory is relative to the
14
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
15
+ #
16
+
17
+ autodoc_mock_imports = ["dlib", "insightface", "onnxruntime"]
18
+ sys.path.insert(0, os.path.abspath("../.."))
19
+
20
+ # -- Project information -----------------------------------------------------
21
+
22
+ project = "FaceEngine"
23
+ copyright = "2019-2026, Daniyar Kussainov"
24
+ author = "Daniyar Kussainov"
25
+
26
+ # The full version, including alpha/beta/rc tags
27
+ from face_engine import __version__
28
+
29
+ release = __version__
30
+
31
+ # -- General configuration ---------------------------------------------------
32
+
33
+ # The master toctree document.
34
+ master_doc = "index"
35
+
36
+ # Add any Sphinx extension module names here, as strings. They can be
37
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
38
+ # ones.
39
+ extensions = ["sphinx.ext.autodoc"]
40
+
41
+ # Add any paths that contain templates here, relative to this directory.
42
+ templates_path = ["_templates"]
43
+
44
+ # List of patterns, relative to source directory, that match files and
45
+ # directories to ignore when looking for source files.
46
+ # This pattern also affects html_static_path and html_extra_path.
47
+ exclude_patterns = []
48
+
49
+ # -- Options for HTML output -------------------------------------------------
50
+
51
+ # The theme to use for HTML and HTML Help pages. See the documentation for
52
+ # a list of builtin themes.
53
+ #
54
+ html_theme = "sphinx_rtd_theme"
55
+
56
+ # Add any paths that contain custom static files (such as style sheets) here,
57
+ # relative to this directory. They are copied after the builtin static files,
58
+ # so a file named "default.css" will overwrite the builtin "default.css".
59
+ html_static_path = []
60
+
61
+ autodoc_member_order = "bysource"
@@ -0,0 +1,16 @@
1
+ """
2
+ Face Recognition Engine
3
+ """
4
+
5
+ __all__ = ["logger", "RESOURCES", "FaceEngine", "_models", "load_engine"]
6
+ __version__ = "3.1.0"
7
+ __author__ = "Daniyar Kussainov"
8
+ __license__ = "Apache License, Version 2.0"
9
+ __copyright__ = "Copyright 2019-2026 Daniyar Kussainov"
10
+
11
+ import logging
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+ from face_engine.fetching import RESOURCES # noqa: E402
16
+ from face_engine.core import FaceEngine, _models, load_engine # noqa: E402