mirror of
https://github.com/serengil/deepface.git
synced 2025-06-04 02:20:06 +00:00
Update README.md
This commit is contained in:
parent
a697ab576a
commit
f084a1aad5
12
README.md
12
README.md
@ -381,24 +381,20 @@ Even though vector embeddings are not reversible to original images, they still
|
||||
```python
|
||||
from lightphe import LightPHE
|
||||
|
||||
# define a plain vectors for source and target
|
||||
alpha = DeepFace.represent("img1.jpg")[0]["embedding"]
|
||||
beta = DeepFace.represent("target.jpg")[0]["embedding"]
|
||||
|
||||
# build an additively homomorphic cryptosystem (e.g. Paillier) on-prem
|
||||
cs = LightPHE(algorithm_name = "Paillier", precision = 19)
|
||||
|
||||
# export keys
|
||||
cs.export_keys("public.txt", public=True)
|
||||
|
||||
# define a plain vector for source (user tower)
|
||||
alpha = DeepFace.represent("img1.jpg")[0]["embedding"]
|
||||
|
||||
# encrypt source embedding
|
||||
encrypted_alpha = cs.encrypt(alpha)
|
||||
|
||||
# restore the cryptosystem in cloud with only public key
|
||||
cloud_cs = LightPHE(algorithm_name = "Paillier", precision = 19, key_file = "public.txt")
|
||||
|
||||
# define a plain vector for target (item tower)
|
||||
beta = DeepFace.represent("target.jpg")[0]["embedding"]
|
||||
|
||||
# dot product of encrypted and plain embedding pair in cloud
|
||||
encrypted_cosine_similarity = encrypted_alpha @ beta
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user