garavv commited on
Commit
224c23c
·
verified ·
1 Parent(s): 150874e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +74 -0
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ArcFace ONNX
2
+
3
+ A high-accuracy face recognition (embedding) model exported to ONNX format, ready to run with [onnxruntime](https://onnxruntime.ai/).
4
+
5
+ - **Input:** Cropped RGB face image, resized to 112x112.
6
+ - **Output:** 512-dimensional embedding (vector).
7
+ - **Use case:** Face verification and recognition (compare two faces for similarity).
8
+
9
+ ---
10
+
11
+ ## 📥 Download Model
12
+
13
+ Download the ONNX model using:
14
+
15
+ ```bash
16
+ wget https://huggingface.co/garavv/arcface-onnx/resolve/main/arc.onnx?download=true -O arcface.onnx
17
+ ```
18
+
19
+ ---
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ```python
24
+ import cv2
25
+ import numpy as np
26
+ import onnxruntime as ort
27
+
28
+ def preprocess(img_path):
29
+ img = cv2.imread(img_path)
30
+ img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
31
+ img = cv2.resize(img, (112, 112))
32
+ img = (img.astype(np.float32) - 127.5) / 128.0
33
+ return img[np.newaxis, ...] # shape: (1, 112, 112, 3)
34
+
35
+ sess = ort.InferenceSession("arcface.onnx")
36
+ input_name = sess.get_inputs()[0].name
37
+ output_name = sess.get_outputs()[0].name
38
+
39
+ emb1 = sess.run([output_name], {input_name: preprocess("face1.jpg")})[0][0]
40
+ emb2 = sess.run([output_name], {input_name: preprocess("face2.jpg")})[0][0]
41
+
42
+ # Normalize
43
+ emb1 = emb1 / np.linalg.norm(emb1)
44
+ emb2 = emb2 / np.linalg.norm(emb2)
45
+ cosine_sim = np.dot(emb1, emb2)
46
+ print("Cosine similarity:", cosine_sim)
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 📦 Dependencies
52
+
53
+ - Python 3.7+
54
+ - onnxruntime
55
+ - numpy
56
+ - opencv-python
57
+
58
+ **Install with:**
59
+
60
+ ```bash
61
+ pip install onnxruntime numpy opencv-python
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 📝 Model Details
67
+
68
+ - **Architecture:** ArcFace (ONNX, 512-dim output)
69
+ - **Input shape:** (1, 112, 112, 3) (batch, height, width, channels)
70
+ - **Output:** (1, 512) embedding vector
71
+
72
+ ---
73
+
74
+