forensicface


Nameforensicface JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/rafribeiro/forensicface
SummaryA package for forensic face examination
upload_time2024-04-23 21:17:06
maintainerNone
docs_urlNone
authorRafael O. Ribeiro
requires_python>=3.8
licenseBSD License
keywords nbdev jupyter python face recognition forensics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # forensicface

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install

``` sh
pip install forensicface
```

Os arquivos onnx dos modelos de detecção (det_10g.onnx), pose
(1k3d68.onnx) e gênero/idade (genderage.onnx) devem estar na pasta
`~/.insightface/model/<model_name>/`

O arquivo onnx do modelo de reconhecimento (adaface_ir101web12m.onnx)
deve estar na pasta `~/.insightface/model/<model_name>/adaface/`

O arquivo onnx do modelo de qualidade CR_FIQA (cr_fiqa_l.onnx) deve
estar na pasta `~/.insightface/model/<model_name>/cr_fiqa/`

O modelo padrão é denominado `sepaelv2`. A partir da versão 0.1.5 é
possível utilizar outros modelos.

## Como utilizar

Importação da classe ForensicFace:

``` python
from forensicface.app import ForensicFace
```

Instanciamento do ForensicFace:

``` python
ff = ForensicFace(det_size=320, use_gpu=True, extended=True)
```

    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}
    find model: /home/rafael/.insightface/models/sepaelv2/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}
    find model: /home/rafael/.insightface/models/sepaelv2/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}
    find model: /home/rafael/.insightface/models/sepaelv2/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
    set det-size: (320, 320)

## Processamento básico de imagens

Obter pontos de referência, distância interpupilar, representação
vetorial, a face alinhada com dimensão fixa (112x112), estimativas de
sexo, idade, pose (*pitch*, *yaw*, *roll*) e qualidade.

``` python
results = ff.process_image_single_face("obama.png")
results.keys()
```

    /home/rafael/miniconda3/envs/ffdev/lib/python3.10/site-packages/insightface/utils/transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
    To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
      P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4

    dict_keys(['keypoints', 'ipd', 'embedding', 'norm', 'bbox', 'aligned_face', 'gender', 'age', 'pitch', 'yaw', 'roll', 'fiqa_score'])

Comparar duas imagens faciais e obter o escore de similaridade.

``` python
ff.compare("obama.png", "obama2.png")
```

    0.8556093

Agregar embeddings de duas imagens faciais em uma única representação,
com ponderação por qualidade

``` python
agg = ff.aggregate_from_images(["obama.png", "obama2.png"], quality_weight=True)
agg.shape
```

    (512,)

## Estimativa de qualidade CR-FIQA

Estimativa de qualidade pelo método
[CR-FIQA](https://github.com/fdbtrs/CR-FIQA)

Para desabilitar, instancie o forensicface com a opção extended = False:

`ff = ForensicFace(extended=False)`

Obs.: a opção `extended = False` também desabilita as estimativas de
sexo, idade e pose.

``` python
good = ff.process_image("001_frontal.jpg")
bad = ff.process_image("001_cam1_1.jpg")
good["fiqa_score"], bad["fiqa_score"]
```

    (2.3786173, 1.4386057)

## Crédito dos modelos utilizados

- Detecção, gênero (M/F), idade e pose (pitch, yaw, roll):
  [insightface](https://github.com/deepinsight/insightface)

- Reconhecimento: [adaface](https://github.com/mk-minchul/AdaFace)

- Estimativa de qualidade: [CR-FIQA](https://github.com/fdbtrs/CR-FIQA)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rafribeiro/forensicface",
    "name": "forensicface",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "nbdev jupyter python face recognition forensics",
    "author": "Rafael O. Ribeiro",
    "author_email": "rafaeloliveiraribeiro@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ef/26/897ba22549d1cb4bb2423a1c614b117f872261a34487d5641d34af000810/forensicface-0.3.4.tar.gz",
    "platform": null,
    "description": "# forensicface\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` sh\npip install forensicface\n```\n\nOs arquivos onnx dos modelos de detec\u00e7\u00e3o (det_10g.onnx), pose\n(1k3d68.onnx) e g\u00eanero/idade (genderage.onnx) devem estar na pasta\n`~/.insightface/model/<model_name>/`\n\nO arquivo onnx do modelo de reconhecimento (adaface_ir101web12m.onnx)\ndeve estar na pasta `~/.insightface/model/<model_name>/adaface/`\n\nO arquivo onnx do modelo de qualidade CR_FIQA (cr_fiqa_l.onnx) deve\nestar na pasta `~/.insightface/model/<model_name>/cr_fiqa/`\n\nO modelo padr\u00e3o \u00e9 denominado `sepaelv2`. A partir da vers\u00e3o 0.1.5 \u00e9\nposs\u00edvel utilizar outros modelos.\n\n## Como utilizar\n\nImporta\u00e7\u00e3o da classe ForensicFace:\n\n``` python\nfrom forensicface.app import ForensicFace\n```\n\nInstanciamento do ForensicFace:\n\n``` python\nff = ForensicFace(det_size=320, use_gpu=True, extended=True)\n```\n\n    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}\n    find model: /home/rafael/.insightface/models/sepaelv2/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0\n    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}\n    find model: /home/rafael/.insightface/models/sepaelv2/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0\n    Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'CUDAExecutionProvider': {'device_id': '0', 'gpu_mem_limit': '18446744073709551615', 'gpu_external_alloc': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'cudnn_conv_algo_search': 'EXHAUSTIVE', 'cudnn_conv1d_pad_to_nc1d': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'enable_cuda_graph': '0', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'enable_skip_layer_norm_strict_mode': '0', 'tunable_op_tuning_enable': '0'}}\n    find model: /home/rafael/.insightface/models/sepaelv2/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0\n    set det-size: (320, 320)\n\n## Processamento b\u00e1sico de imagens\n\nObter pontos de refer\u00eancia, dist\u00e2ncia interpupilar, representa\u00e7\u00e3o\nvetorial, a face alinhada com dimens\u00e3o fixa (112x112), estimativas de\nsexo, idade, pose (*pitch*, *yaw*, *roll*) e qualidade.\n\n``` python\nresults = ff.process_image_single_face(\"obama.png\")\nresults.keys()\n```\n\n    /home/rafael/miniconda3/envs/ffdev/lib/python3.10/site-packages/insightface/utils/transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.\n    To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.\n      P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4\n\n    dict_keys(['keypoints', 'ipd', 'embedding', 'norm', 'bbox', 'aligned_face', 'gender', 'age', 'pitch', 'yaw', 'roll', 'fiqa_score'])\n\nComparar duas imagens faciais e obter o escore de similaridade.\n\n``` python\nff.compare(\"obama.png\", \"obama2.png\")\n```\n\n    0.8556093\n\nAgregar embeddings de duas imagens faciais em uma \u00fanica representa\u00e7\u00e3o,\ncom pondera\u00e7\u00e3o por qualidade\n\n``` python\nagg = ff.aggregate_from_images([\"obama.png\", \"obama2.png\"], quality_weight=True)\nagg.shape\n```\n\n    (512,)\n\n## Estimativa de qualidade CR-FIQA\n\nEstimativa de qualidade pelo m\u00e9todo\n[CR-FIQA](https://github.com/fdbtrs/CR-FIQA)\n\nPara desabilitar, instancie o forensicface com a op\u00e7\u00e3o extended = False:\n\n`ff = ForensicFace(extended=False)`\n\nObs.: a op\u00e7\u00e3o `extended = False` tamb\u00e9m desabilita as estimativas de\nsexo, idade e pose.\n\n``` python\ngood = ff.process_image(\"001_frontal.jpg\")\nbad = ff.process_image(\"001_cam1_1.jpg\")\ngood[\"fiqa_score\"], bad[\"fiqa_score\"]\n```\n\n    (2.3786173, 1.4386057)\n\n## Cr\u00e9dito dos modelos utilizados\n\n- Detec\u00e7\u00e3o, g\u00eanero (M/F), idade e pose (pitch, yaw, roll):\n  [insightface](https://github.com/deepinsight/insightface)\n\n- Reconhecimento: [adaface](https://github.com/mk-minchul/AdaFace)\n\n- Estimativa de qualidade: [CR-FIQA](https://github.com/fdbtrs/CR-FIQA)\n",
    "bugtrack_url": null,
    "license": "BSD License",
    "summary": "A package for forensic face examination",
    "version": "0.3.4",
    "project_urls": {
        "Homepage": "https://github.com/rafribeiro/forensicface"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "python",
        "face",
        "recognition",
        "forensics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22cb611ecfb30c7c7c74a9d471e4a71aa466a160f40057a9226a6e757ed54247",
                "md5": "69adf6d5cf1c1cc6ccb21454fa9819cc",
                "sha256": "c8d6ab005cbe1d8ad13151a015bdbb8891291ef6b058adcb8e44d41f920a4cc2"
            },
            "downloads": -1,
            "filename": "forensicface-0.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69adf6d5cf1c1cc6ccb21454fa9819cc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13199,
            "upload_time": "2024-04-23T21:17:04",
            "upload_time_iso_8601": "2024-04-23T21:17:04.519791Z",
            "url": "https://files.pythonhosted.org/packages/22/cb/611ecfb30c7c7c74a9d471e4a71aa466a160f40057a9226a6e757ed54247/forensicface-0.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef26897ba22549d1cb4bb2423a1c614b117f872261a34487d5641d34af000810",
                "md5": "befe85d7b94ba15dd017448eb6f35c8e",
                "sha256": "e0eb4ed26ae0ef86cfb09f99f0ba85765044a073538d65214074f453d62456ca"
            },
            "downloads": -1,
            "filename": "forensicface-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "befe85d7b94ba15dd017448eb6f35c8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14323,
            "upload_time": "2024-04-23T21:17:06",
            "upload_time_iso_8601": "2024-04-23T21:17:06.543882Z",
            "url": "https://files.pythonhosted.org/packages/ef/26/897ba22549d1cb4bb2423a1c614b117f872261a34487d5641d34af000810/forensicface-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-23 21:17:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rafribeiro",
    "github_project": "forensicface",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "forensicface"
}
        
Elapsed time: 0.24887s