forensicface


Nameforensicface JSON
Version 0.3.10 PyPI version JSON
download
home_pagehttps://github.com/rafribeiro/forensicface
SummaryA package for forensic face examination
upload_time2024-12-08 12:02:23
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. Opcionalmente, é
possível anotar a face alinhada com os pontos de referência utilizados
no alinhamento (parâmetro `draw_kypoints`).

``` python
results = ff.process_image_single_face("obama2.png", draw_keypoints=True)
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', 'det_score', 'aligned_face', 'gender', 'age', 'pitch', 'yaw', 'roll', 'fiqa_score'])

``` python
plt.imshow(results["aligned_face"])
```

![](index_files/figure-commonmark/cell-5-output-1.png)

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/ec/cf/c160b6e73bde1e98551d87172dd864508301767a5085e7a6f30f81616821/forensicface-0.3.10.tar.gz",
    "platform": null,
    "description": "# forensicface\n\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. Opcionalmente, \u00e9\nposs\u00edvel anotar a face alinhada com os pontos de refer\u00eancia utilizados\nno alinhamento (par\u00e2metro `draw_kypoints`).\n\n``` python\nresults = ff.process_image_single_face(\"obama2.png\", draw_keypoints=True)\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', 'det_score', 'aligned_face', 'gender', 'age', 'pitch', 'yaw', 'roll', 'fiqa_score'])\n\n``` python\nplt.imshow(results[\"aligned_face\"])\n```\n\n![](index_files/figure-commonmark/cell-5-output-1.png)\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.10",
    "project_urls": {
        "Homepage": "https://github.com/rafribeiro/forensicface"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "python",
        "face",
        "recognition",
        "forensics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbe4753dbb6f692bfdc4cd9821f986cc24dd09e6e372b548f6bd7d2993572425",
                "md5": "2253e6beb0d63796b1b907b9f216bdaa",
                "sha256": "608a58c3ddedf26261010da067e10068be84bdefa88c2e71ba81196214e383c8"
            },
            "downloads": -1,
            "filename": "forensicface-0.3.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2253e6beb0d63796b1b907b9f216bdaa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15974,
            "upload_time": "2024-12-08T12:02:21",
            "upload_time_iso_8601": "2024-12-08T12:02:21.558236Z",
            "url": "https://files.pythonhosted.org/packages/db/e4/753dbb6f692bfdc4cd9821f986cc24dd09e6e372b548f6bd7d2993572425/forensicface-0.3.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eccfc160b6e73bde1e98551d87172dd864508301767a5085e7a6f30f81616821",
                "md5": "d959da3c1b5b415d6bfb8f1017bb0cfa",
                "sha256": "c0893a65ab07220df8f0b00bdde3905f9a4421e8c1e4f429787c17df0b549665"
            },
            "downloads": -1,
            "filename": "forensicface-0.3.10.tar.gz",
            "has_sig": false,
            "md5_digest": "d959da3c1b5b415d6bfb8f1017bb0cfa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16759,
            "upload_time": "2024-12-08T12:02:23",
            "upload_time_iso_8601": "2024-12-08T12:02:23.456402Z",
            "url": "https://files.pythonhosted.org/packages/ec/cf/c160b6e73bde1e98551d87172dd864508301767a5085e7a6f30f81616821/forensicface-0.3.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-08 12:02:23",
    "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.49562s