insightface


Nameinsightface JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://github.com/deepinsight/insightface
SummaryInsightFace Python Library
upload_time2023-04-02 08:01:54
maintainer
docs_urlNone
authorInsightFace Contributors
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            InsightFace Python Library
==========================

License
-------

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
-------

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)
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deepinsight/insightface",
    "name": "insightface",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "InsightFace Contributors",
    "author_email": "contact@insightface.ai",
    "download_url": "https://files.pythonhosted.org/packages/0b/8d/0f4af90999ca96cf8cb846eb5ae27c5ef5b390f9c090dd19e4fa76364c13/insightface-0.7.3.tar.gz",
    "platform": null,
    "description": "InsightFace Python Library\n==========================\n\nLicense\n-------\n\nThe code of InsightFace Python Library is released under the MIT\nLicense. There is no limitation for both academic and commercial usage.\n\n**The pretrained models we provided with this library are available for\nnon-commercial research purposes only, including both auto-downloading\nmodels and manual-downloading models.**\n\nInstall\n-------\n\nInstall Inference Backend\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFor ``insightface<=0.1.5``, we use MXNet as inference backend.\n\nStarting from insightface>=0.2, we use onnxruntime as inference backend.\n\nYou have to install ``onnxruntime-gpu`` manually to enable GPU\ninference, or install ``onnxruntime`` to use CPU only inference.\n\nChange Log\n----------\n\n[0.7.1] - 2022-12-14\n~~~~~~~~~~~~~~~~~~~~\n\nChanged\n^^^^^^^\n\n-  Change model downloading provider to cloudfront.\n\n.. _section-1:\n\n[0.7] - 2022-11-28\n~~~~~~~~~~~~~~~~~~\n\nAdded\n^^^^^\n\n-  Add face swapping model and example.\n\n.. _changed-1:\n\nChanged\n^^^^^^^\n\n-  Set default ORT provider to CUDA and CPU.\n\n.. _section-2:\n\n[0.6] - 2022-01-29\n~~~~~~~~~~~~~~~~~~\n\n.. _added-1:\n\nAdded\n^^^^^\n\n-  Add pose estimation in face-analysis app.\n\n.. _changed-2:\n\nChanged\n^^^^^^^\n\n-  Change model automated downloading url, to ucloud.\n\nQuick Example\n-------------\n\n::\n\n   import cv2\n   import numpy as np\n   import insightface\n   from insightface.app import FaceAnalysis\n   from insightface.data import get_image as ins_get_image\n\n   app = FaceAnalysis(providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])\n   app.prepare(ctx_id=0, det_size=(640, 640))\n   img = ins_get_image('t1')\n   faces = app.get(img)\n   rimg = app.draw_on(img, faces)\n   cv2.imwrite(\"./t1_output.jpg\", rimg)\n\nThis quick example will detect faces from the ``t1.jpg`` image and draw\ndetection results on it.\n\nModel Zoo\n---------\n\nIn the latest version of insightface library, we provide following model\npacks:\n\nName in **bold** is the default model pack. **Auto** means we can\ndownload the model pack through the python library directly.\n\nOnce you manually downloaded the zip model pack, unzip it under\n``~/.insightface/models/`` first before you call the program.\n\n+-----+------+--------+----+---+---+---------------------------+-----+\n| Nam | Dete | Recogn | Al | A | M | Link                      | Aut |\n| e   | ctio | ition  | ig | t | o |                           | o   |\n|     | n    | Model  | nm | t | d |                           |     |\n|     | Mode |        | en | r | e |                           |     |\n|     | l    |        | t  | i | l |                           |     |\n|     |      |        |    | b | - |                           |     |\n|     |      |        |    | u | S |                           |     |\n|     |      |        |    | t | i |                           |     |\n|     |      |        |    | e | z |                           |     |\n|     |      |        |    | s | e |                           |     |\n+=====+======+========+====+===+===+===========================+=====+\n| ant | SCRF | ResNet | 2d | G | 4 | `link <https://drive.goog | N   |\n| elo | D-10 | 100@Gl | 10 | e | 0 | le.com/file/d/18wEUfMNohB |     |\n| pev | GF   | int360 | 6  | n | 7 | J4K3Ly5wpTejPfDzp-8fI8/vi |     |\n| 2   |      | K      | &  | d | M | ew?usp=sharing>`__        |     |\n|     |      |        | 3d | e | B |                           |     |\n|     |      |        | 68 | r |   |                           |     |\n|     |      |        |    | & |   |                           |     |\n|     |      |        |    | A |   |                           |     |\n|     |      |        |    | g |   |                           |     |\n|     |      |        |    | e |   |                           |     |\n+-----+------+--------+----+---+---+---------------------------+-----+\n| **b | SCRF | ResNet | 2d | G | 3 | `link <https://drive.goog | Y   |\n| uff | D-10 | 50@Web | 10 | e | 2 | le.com/file/d/1qXsQJ8ZT42 |     |\n| alo | GF   | Face60 | 6  | n | 6 | _xSmWIYy85IcidpiZudOCB/vi |     |\n| _l* |      | 0K     | &  | d | M | ew?usp=sharing>`__        |     |\n| *   |      |        | 3d | e | B |                           |     |\n|     |      |        | 68 | r |   |                           |     |\n|     |      |        |    | & |   |                           |     |\n|     |      |        |    | A |   |                           |     |\n|     |      |        |    | g |   |                           |     |\n|     |      |        |    | e |   |                           |     |\n+-----+------+--------+----+---+---+---------------------------+-----+\n| buf | SCRF | ResNet | 2d | G | 3 | `link <https://drive.goog | N   |\n| fal | D-2. | 50@Web | 10 | e | 1 | le.com/file/d/1net68yNxF3 |     |\n| o_m | 5GF  | Face60 | 6  | n | 3 | 3NNV6WP7k56FS6V53tq-64/vi |     |\n|     |      | 0K     | &  | d | M | ew?usp=sharing>`__        |     |\n|     |      |        | 3d | e | B |                           |     |\n|     |      |        | 68 | r |   |                           |     |\n|     |      |        |    | & |   |                           |     |\n|     |      |        |    | A |   |                           |     |\n|     |      |        |    | g |   |                           |     |\n|     |      |        |    | e |   |                           |     |\n+-----+------+--------+----+---+---+---------------------------+-----+\n| buf | SCRF | MBF@We | 2d | G | 1 | `link <https://drive.goog | N   |\n| fal | D-50 | bFace6 | 10 | e | 5 | le.com/file/d/1pKIusApEfo |     |\n| o_s | 0MF  | 00K    | 6  | n | 9 | HKDjeBTXYB3yOQ0EtTonNE/vi |     |\n|     |      |        | &  | d | M | ew?usp=sharing>`__        |     |\n|     |      |        | 3d | e | B |                           |     |\n|     |      |        | 68 | r |   |                           |     |\n|     |      |        |    | & |   |                           |     |\n|     |      |        |    | A |   |                           |     |\n|     |      |        |    | g |   |                           |     |\n|     |      |        |    | e |   |                           |     |\n+-----+------+--------+----+---+---+---------------------------+-----+\n| buf | SCRF | MBF@We | -  | - | 1 | `link <https://drive.goog | N   |\n| fal | D-50 | bFace6 |    |   | 6 | le.com/file/d/19I-MZdctYK |     |\n| o_s | 0MF  | 00K    |    |   | M | mVf3nu5Da3HS6KH5LBfdzG/vi |     |\n| c   |      |        |    |   | B | ew?usp=sharing>`__        |     |\n+-----+------+--------+----+---+---+---------------------------+-----+\n\nRecognition Accuracy:\n\n+-------+----+-----+-------+--------+--------+---+----+------+-------+\n| Name  | MR | Afr | Cauca | South  | East   | L | CF | AgeD | IJB-C |\n|       | -A | ica | sian  | Asian  | Asian  | F | P- | B-30 | (E4)  |\n|       | LL | n   |       |        |        | W | FP |      |       |\n+=======+====+=====+=======+========+========+===+====+======+=======+\n| buffa | 91 | 90. | 94.70 | 93.16  | 74.96  | 9 | 99 | 98.2 | 97.25 |\n| lo_l  | .2 | 29  |       |        |        | 9 | .3 | 3    |       |\n|       | 5  |     |       |        |        | . | 3  |      |       |\n|       |    |     |       |        |        | 8 |    |      |       |\n|       |    |     |       |        |        | 3 |    |      |       |\n+-------+----+-----+-------+--------+--------+---+----+------+-------+\n| buffa | 71 | 69. | 80.45 | 73.39  | 51.03  | 9 | 98 | 96.5 | 95.02 |\n| lo_s  | .8 | 45  |       |        |        | 9 | .0 | 8    |       |\n|       | 7  |     |       |        |        | . | 0  |      |       |\n|       |    |     |       |        |        | 7 |    |      |       |\n|       |    |     |       |        |        | 0 |    |      |       |\n+-------+----+-----+-------+--------+--------+---+----+------+-------+\n\n*buffalo_m has the same accuracy with buffalo_l.*\n\n*buffalo_sc has the same accuracy with buffalo_s.*\n\n**Note that these models are available for non-commercial research\npurposes only.**\n\nFor insightface>=0.3.3, models will be downloaded automatically once we\ninit ``app = FaceAnalysis()`` instance.\n\nFor insightface==0.3.2, you must first download the model package by\ncommand:\n\n::\n\n   insightface-cli model.download buffalo_l\n\nUse Your Own Licensed Model\n---------------------------\n\nYou can simply create a new model directory under\n``~/.insightface/models/`` and replace the pretrained models we provide\nwith your own models. And then call\n``app = FaceAnalysis(name='your_model_zoo')`` to load these models.\n\nCall Models\n-----------\n\nThe latest insightface libary only supports onnx models. Once you have\ntrained detection or recognition models by PyTorch, MXNet or any other\nframeworks, you can convert it to the onnx format and then they can be\ncalled with insightface library.\n\nCall Detection Models\n~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n   import cv2\n   import numpy as np\n   import insightface\n   from insightface.app import FaceAnalysis\n   from insightface.data import get_image as ins_get_image\n\n   # Method-1, use FaceAnalysis\n   app = FaceAnalysis(allowed_modules=['detection']) # enable detection model only\n   app.prepare(ctx_id=0, det_size=(640, 640))\n\n   # Method-2, load model directly\n   detector = insightface.model_zoo.get_model('your_detection_model.onnx')\n   detector.prepare(ctx_id=0, input_size=(640, 640))\n\nCall Recognition Models\n~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n   import cv2\n   import numpy as np\n   import insightface\n   from insightface.app import FaceAnalysis\n   from insightface.data import get_image as ins_get_image\n\n   handler = insightface.model_zoo.get_model('your_recognition_model.onnx')\n   handler.prepare(ctx_id=0)",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "InsightFace Python Library",
    "version": "0.7.3",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b8d0f4af90999ca96cf8cb846eb5ae27c5ef5b390f9c090dd19e4fa76364c13",
                "md5": "ea173bd9f5145c4d93212d8cdb5cb36d",
                "sha256": "f191f719612ebb37018f41936814500544cd0f86e6fcd676c023f354c668ddf7"
            },
            "downloads": -1,
            "filename": "insightface-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ea173bd9f5145c4d93212d8cdb5cb36d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 439490,
            "upload_time": "2023-04-02T08:01:54",
            "upload_time_iso_8601": "2023-04-02T08:01:54.541223Z",
            "url": "https://files.pythonhosted.org/packages/0b/8d/0f4af90999ca96cf8cb846eb5ae27c5ef5b390f9c090dd19e4fa76364c13/insightface-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-02 08:01:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "deepinsight",
    "github_project": "insightface",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "insightface"
}
        
Elapsed time: 0.27131s