Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The code of InsightFace Python Library is released under the MIT License. There is no limitation for both academic and commercial usage.
The pretrained models we provided with this library are available for non-commercial research purposes only, including both auto-downloading models and manual-downloading models.
Install Inference Backend
For ``insightface<=0.1.5``, we use MXNet as inference backend.
Starting from insightface>=0.2, we use onnxruntime as inference backend.
You have to install ``onnxruntime-gpu`` manually to enable GPU
inference, or install ``onnxruntime`` to use CPU only inference.
Change Log
----------
[0.7.1] - 2022-12-14
~~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
- Change model downloading provider to cloudfront.
.. _section-1:
[0.7] - 2022-11-28
~~~~~~~~~~~~~~~~~~
Added
^^^^^
- Add face swapping model and example.
.. _changed-1:
Changed
^^^^^^^
- Set default ORT provider to CUDA and CPU.
.. _section-2:
[0.6] - 2022-01-29
~~~~~~~~~~~~~~~~~~
.. _added-1:
Added
^^^^^
- Add pose estimation in face-analysis app.
.. _changed-2:
Changed
^^^^^^^
- Change model automated downloading url, to ucloud.
Quick Example
-------------
::
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
app.prepare(ctx_id=0, det_size=(640, 640))
img = ins_get_image('t1')
faces = app.get(img)
rimg = app.draw_on(img, faces)
cv2.imwrite("./t1_output.jpg", rimg)
This quick example will detect faces from the ``t1.jpg`` image and draw
detection results on it.
Model Zoo
---------
In the latest version of insightface library, we provide following model
packs:
Name in **bold** is the default model pack. **Auto** means we can
download the model pack through the python library directly.
Once you manually downloaded the zip model pack, unzip it under
``~/.insightface/models/`` first before you call the program.
+-----+------+--------+----+---+---+---------------------------+-----+
| Nam | Dete | Recogn | Al | A | M | Link | Aut |
| e | ctio | ition | ig | t | o | | o |
| | n | Model | nm | t | d | | |
| | Mode | | en | r | e | | |
| | l | | t | i | l | | |
| | | | | b | - | | |
| | | | | u | S | | |
| | | | | t | i | | |
| | | | | e | z | | |
| | | | | s | e | | |
+=====+======+========+====+===+===+===========================+=====+
| ant | SCRF | ResNet | 2d | G | 4 | `link <https://drive.goog | N |
| elo | D-10 | 100@Gl | 10 | e | 0 | le.com/file/d/18wEUfMNohB | |
| pev | GF | int360 | 6 | n | 7 | J4K3Ly5wpTejPfDzp-8fI8/vi | |
| 2 | | K | & | d | M | ew?usp=sharing>`__ | |
| | | | 3d | e | B | | |
| | | | 68 | r | | | |
| | | | | & | | | |
| | | | | A | | | |
| | | | | g | | | |
| | | | | e | | | |
+-----+------+--------+----+---+---+---------------------------+-----+
| **b | SCRF | ResNet | 2d | G | 3 | `link <https://drive.goog | Y |
| uff | D-10 | 50@Web | 10 | e | 2 | le.com/file/d/1qXsQJ8ZT42 | |
| alo | GF | Face60 | 6 | n | 6 | _xSmWIYy85IcidpiZudOCB/vi | |
| _l* | | 0K | & | d | M | ew?usp=sharing>`__ | |
| * | | | 3d | e | B | | |
| | | | 68 | r | | | |
| | | | | & | | | |
| | | | | A | | | |
| | | | | g | | | |
| | | | | e | | | |
+-----+------+--------+----+---+---+---------------------------+-----+
| buf | SCRF | ResNet | 2d | G | 3 | `link <https://drive.goog | N |
| fal | D-2. | 50@Web | 10 | e | 1 | le.com/file/d/1net68yNxF3 | |
| o_m | 5GF | Face60 | 6 | n | 3 | 3NNV6WP7k56FS6V53tq-64/vi | |
| | | 0K | & | d | M | ew?usp=sharing>`__ | |
| | | | 3d | e | B | | |
| | | | 68 | r | | | |
| | | | | & | | | |
| | | | | A | | | |
| | | | | g | | | |
| | | | | e | | | |
+-----+------+--------+----+---+---+---------------------------+-----+
| buf | SCRF | MBF@We | 2d | G | 1 | `link <https://drive.goog | N |
| fal | D-50 | bFace6 | 10 | e | 5 | le.com/file/d/1pKIusApEfo | |
| o_s | 0MF | 00K | 6 | n | 9 | HKDjeBTXYB3yOQ0EtTonNE/vi | |
| | | | & | d | M | ew?usp=sharing>`__ | |
| | | | 3d | e | B | | |
| | | | 68 | r | | | |
| | | | | & | | | |
| | | | | A | | | |
| | | | | g | | | |
| | | | | e | | | |
+-----+------+--------+----+---+---+---------------------------+-----+
| buf | SCRF | MBF@We | - | - | 1 | `link <https://drive.goog | N |
| fal | D-50 | bFace6 | | | 6 | le.com/file/d/19I-MZdctYK | |
| o_s | 0MF | 00K | | | M | mVf3nu5Da3HS6KH5LBfdzG/vi | |
| c | | | | | B | ew?usp=sharing>`__ | |
+-----+------+--------+----+---+---+---------------------------+-----+
Recognition Accuracy:
+-------+----+-----+-------+--------+--------+---+----+------+-------+
| Name | MR | Afr | Cauca | South | East | L | CF | AgeD | IJB-C |
| | -A | ica | sian | Asian | Asian | F | P- | B-30 | (E4) |
| | LL | n | | | | W | FP | | |
+=======+====+=====+=======+========+========+===+====+======+=======+
| buffa | 91 | 90. | 94.70 | 93.16 | 74.96 | 9 | 99 | 98.2 | 97.25 |
| lo_l | .2 | 29 | | | | 9 | .3 | 3 | |
| | 5 | | | | | . | 3 | | |
| | | | | | | 8 | | | |
| | | | | | | 3 | | | |
+-------+----+-----+-------+--------+--------+---+----+------+-------+
| buffa | 71 | 69. | 80.45 | 73.39 | 51.03 | 9 | 98 | 96.5 | 95.02 |
| lo_s | .8 | 45 | | | | 9 | .0 | 8 | |
| | 7 | | | | | . | 0 | | |
| | | | | | | 7 | | | |
| | | | | | | 0 | | | |
+-------+----+-----+-------+--------+--------+---+----+------+-------+
*buffalo_m has the same accuracy with buffalo_l.*
*buffalo_sc has the same accuracy with buffalo_s.*
**Note that these models are available for non-commercial research
purposes only.**
For insightface>=0.3.3, models will be downloaded automatically once we
init ``app = FaceAnalysis()`` instance.
For insightface==0.3.2, you must first download the model package by
command:
::
insightface-cli model.download buffalo_l
Use Your Own Licensed Model
---------------------------
You can simply create a new model directory under
``~/.insightface/models/`` and replace the pretrained models we provide
with your own models. And then call
``app = FaceAnalysis(name='your_model_zoo')`` to load these models.
Call Models
-----------
The latest insightface libary only supports onnx models. Once you have
trained detection or recognition models by PyTorch, MXNet or any other
frameworks, you can convert it to the onnx format and then they can be
called with insightface library.
Call Detection Models
~~~~~~~~~~~~~~~~~~~~~
::
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
# Method-1, use FaceAnalysis
app = FaceAnalysis(allowed_modules=['detection']) # enable detection model only
app.prepare(ctx_id=0, det_size=(640, 640))
# Method-2, load model directly
detector = insightface.model_zoo.get_model('your_detection_model.onnx')
detector.prepare(ctx_id=0, input_size=(640, 640))
Call Recognition Models
~~~~~~~~~~~~~~~~~~~~~~~
::
import cv2
import numpy as np
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
handler = insightface.model_zoo.get_model('your_recognition_model.onnx')
handler.prepare(ctx_id=0)
FAQs
InsightFace Python Library
We found that insightface demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.