Spaces:
Running
Running
Duplicate from VishyVish/Face-ID-duplicated
Browse filesCo-authored-by: Vishal Singh <VishyVish@users.noreply.huggingface.co>
- .gitattributes +31 -0
- README.md +13 -0
- app.py +31 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Face ID
|
3 |
+
emoji: ⚡
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.4.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: VishyVish/Face-ID-duplicated
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
2 |
+
from sentence_transformers import SentenceTransformer
|
3 |
+
import datasets
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
#model = SentenceTransformer('clip-ViT-B-16')
|
7 |
+
model = SentenceTransformer('clip-ViT-B-32')
|
8 |
+
dataset = datasets.load_dataset('brendenc/celeb-identities')
|
9 |
+
|
10 |
+
def predict(im1, im2):
|
11 |
+
|
12 |
+
embeddings = model.encode([im1, im2])
|
13 |
+
sim = cosine_similarity(embeddings)
|
14 |
+
sim = sim[0, 1]
|
15 |
+
if sim > 0.82:
|
16 |
+
return sim, "SAME PERSON, AUTHORIZE PAYMENT"
|
17 |
+
else:
|
18 |
+
return sim, "DIFFERENT PEOPLE, DON'T AUTHORIZE PAYMENT"
|
19 |
+
|
20 |
+
|
21 |
+
interface = gr.Interface(fn=predict,
|
22 |
+
inputs= [gr.Image(value = dataset['train']['image'][10], type="pil", source="webcam"),
|
23 |
+
gr.Image(value = dataset['train']['image'][17], type="pil", source="webcam")],
|
24 |
+
outputs= [gr.Number(label="Similarity"),
|
25 |
+
gr.Textbox(label="Message")],
|
26 |
+
title = 'Face ID',
|
27 |
+
description = 'This app uses face biometrics and a similarity to function as a Face ID application.The similarity score ranges from -1 to 1.'
|
28 |
+
)
|
29 |
+
|
30 |
+
interface.launch(debug=True)
|
31 |
+
#interface.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
scikit-learn
|
2 |
+
datasets
|
3 |
+
sentence_transformers
|