Identity Similarity
This repository can helps researchers that want to use face recognition in their researches. You can easly implement powerfull face recognition in your project. I motivated for this repository from LPIPS. The models are borrowed from Insigtface.
Warning : Please, be careful when chosing your criterion. Lower is more similar in MSE while higher is more similar in CosineSimilarity.
Usage
1. Training with preprocessed dataset.
In this case, we assume that you have aligned images using a keypoint template and you want to calculate identity similarity between two aligned images or a image and a saved identity vector.
import torch
import numpy as np
from idsim import IdentitySimilarity
idsim = IdentitySimilarity()
template = np.array([[35.066223, 34.23266],
[84.1586, 33.96113],
[59.768444, 62.152763],
[39.60066, 90.89288],
[80.255, 90.66802]], dtype=np.float32)
idsim.set_ref_point(template)
# dummy variables
v1 = torch.rand(1, 512)
im1 = torch.rand(5, 3, 128, 128)
# useful functions
sim_v2v = idsim.forward_v2v(v1, v1)
sim_im2im = idsim.forward_img2img(im1, im1)
sim_v2im = idsim.forward_v2img(v1, im1)
print("\nsim_v2v :", sim_v2v, "\nsim_im2im :", sim_im2im, "\nsim_v2im :", sim_v2im)
2. Face recognition
In this case, Idsim can caculate identity similarity of your images.
import cv2
from idsim import IdentitySimilarity
idsim = IdentitySimilarity(criterion="Cosine")
img1 = cv2.imread("a.jpg")
img2 = cv2.imread("b.jpg")
v1 = idsim.extract_identity(img1)
v2 = idsim.extract_identity(img2)
sim = idsim.forward_v2v(v1,v2)
print("Similarity :", sim)
Note: You can check the proving_differentiability.ipynb for an example training.
Todo
- [] Release pypi package
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Run
make style && make qualityin the root repo directory, to ensure code quality. - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Metadata
Release files for idsim 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| idsim-0.0.1.tar.gz | 13.6 kB | Without provenance | Details for idsim-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| idsim-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for idsim-0.0.1-py3-none-any.whl |
Total release size: 29.8 kB
Release files / idsim-0.0.1.tar.gz
| Download URL | idsim-0.0.1.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da932ef0b698ebfb0048c944d2a6f3e910476c35d8798337cc3a69c389bd44a3
|
|
BLAKE2b-256 checksum How to use checksums |
4b426c15ea8d4f5a2295821c245cac5f3af7e347dae97ab24f548f0ebe29ce41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.12
|
Release files / idsim-0.0.1-py3-none-any.whl
| Download URL | idsim-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d53b2f7907983d4b1633cc23cb2275e6ca283fc7c0b3b6ff6cf83ee25401a04
|
|
BLAKE2b-256 checksum How to use checksums |
9c01b2232f5ac35d678ab0d24c797d1f46d93fcb3de728af67851c7aa93e0f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.12
|
Security for idsim 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.