Skip to main content

ArcFace face recognition implementation in Tensorflow Light.

Project description

ArcFace face recognition

Implementation of the [https://openaccess.thecvf.com/content_CVPR_2019/html/Deng_ArcFace_Additive_Angular_Margin_Loss_for_Deep_Face_Recognition_CVPR_2019_paper.html](ArcFace face recognition algorithm). It includes a pre-trained model based on https://arxiv.org/abs/1512.03385.

The code is based onhttps://github.com/peteryuX/arcface-tf2 implementation. Instead of using full Tensorflow for the inference, the model has been converted to a Tensorflow light model using tf.lite.TFLiteConverter which increased the speed of the inference by ~25%.

Installation

You can install the package through pip:

pip install arcface

Quick-Start

The following example illustrates the ease of use of this package:

>>> from arcface import ArcFace
>>> face_rec = ArcFace.ArcFace()
>>> emb1 = face_rec.calc_emb("~/Downloads/test.jpg")
>>> print(emb1)
array([-1.70827676e-02, -2.69084200e-02, -5.85994311e-02,  3.33652040e-03,
        9.58345132e-04,  1.21807214e-02, -6.81217164e-02, -1.33364811e-03,
       -2.12905575e-02,  1.67165045e-02,  3.52908894e-02, -5.26051633e-02,
	   ...
       -2.11241804e-02,  2.22553015e-02, -5.71946353e-02, -2.33468022e-02],
      dtype=float32)
>>> emb2 = face_rec.calc_emb("~/Downloads/test2.jpg")
>>> face_rec.get_distance_embeddings(emb1, emb2)
0.78542

You can feed the calc_emb function either a single image or an array of images. Furthermore, you can supply the image as (absolute or relative) path, or an cv2-image. To make it more clear, hear are the four possibilities:

  1. (Absolute or relative) path to a single image: face_rec.calc_emb("test.jpg")
  2. Array of images: face_rec.calc_emb(["test1.jpg", "test2.png"])
  3. Single cv2-image: face_rec.calc_emb(cv2.imread("test.png"))
  4. Array of cv2-images: face_rec.calc_emb([cv2.imread("test1.jpg"), cv2.imread("test2.png")])

The face recognition tool returns (an array of) 512-d embedding(s) as a numpy array.

Notice! This package does neither perform face detection nor face alignment! It assumes that the images are already pre-processsed!

License

Licensed under the https://joinup.ec.europa.eu/sites/default/files/custom-page/attachment/2020-03/EUPL-1.2%20EN.txt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arcface-0.0.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

arcface-0.0.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file arcface-0.0.1.tar.gz.

File metadata

  • Download URL: arcface-0.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for arcface-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e69e8c9a14e3706a33b08f410f367a2e849be2745c220e357a025ecc3ec23f00
MD5 8d107de933f497c23dcdb26d0322ca75
BLAKE2b-256 bab3093f295ea9d42230aa8f8166ccf432da005711fac17fd8cf5adc10aacb37

See more details on using hashes here.

File details

Details for the file arcface-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: arcface-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.3

File hashes

Hashes for arcface-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02815056b068f25436052f41c584f391f967b90228de73f32b80f9f7ac8b465c
MD5 e54ee03c8965b3d2df550b9a4f76304e
BLAKE2b-256 cc150fb59f5920a5f919f099d33d014c80c97a36a6c5f9243cebb7d6c995afd6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page