Spaces:
Sleeping
Sleeping
shiveshnavin
commited on
Commit
·
089e31f
1
Parent(s):
0a89c71
Add notebook
Browse files- notebook.ipynb +188 -0
notebook.ipynb
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": [],
|
7 |
+
"mount_file_id": "https://github.com/shiveshnavin/face-match/blob/main/Face_Match.ipynb",
|
8 |
+
"authorship_tag": "ABX9TyOtcib13s1Sgzm0u1C/LhwW",
|
9 |
+
"include_colab_link": true
|
10 |
+
},
|
11 |
+
"kernelspec": {
|
12 |
+
"name": "python3",
|
13 |
+
"display_name": "Python 3"
|
14 |
+
},
|
15 |
+
"language_info": {
|
16 |
+
"name": "python"
|
17 |
+
}
|
18 |
+
},
|
19 |
+
"cells": [
|
20 |
+
{
|
21 |
+
"cell_type": "markdown",
|
22 |
+
"metadata": {
|
23 |
+
"id": "view-in-github",
|
24 |
+
"colab_type": "text"
|
25 |
+
},
|
26 |
+
"source": [
|
27 |
+
"<a href=\"https://colab.research.google.com/github/shiveshnavin/face-match/blob/main/Face_Match.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"cell_type": "code",
|
32 |
+
"execution_count": null,
|
33 |
+
"metadata": {
|
34 |
+
"id": "sKpUFCOofQWa"
|
35 |
+
},
|
36 |
+
"outputs": [],
|
37 |
+
"source": [
|
38 |
+
"!pip install deepface"
|
39 |
+
]
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"cell_type": "code",
|
43 |
+
"source": [
|
44 |
+
"from deepface import DeepFace"
|
45 |
+
],
|
46 |
+
"metadata": {
|
47 |
+
"id": "PFKyr3S3js5g"
|
48 |
+
},
|
49 |
+
"execution_count": null,
|
50 |
+
"outputs": []
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"cell_type": "code",
|
54 |
+
"source": [
|
55 |
+
"import os"
|
56 |
+
],
|
57 |
+
"metadata": {
|
58 |
+
"id": "JN2LNi7wlluR"
|
59 |
+
},
|
60 |
+
"execution_count": null,
|
61 |
+
"outputs": []
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"source": [
|
66 |
+
"dir = '/content/drive/MyDrive/colab/face-match'"
|
67 |
+
],
|
68 |
+
"metadata": {
|
69 |
+
"id": "P6I4Q5poju2r"
|
70 |
+
},
|
71 |
+
"execution_count": null,
|
72 |
+
"outputs": []
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"cell_type": "code",
|
76 |
+
"source": [
|
77 |
+
"!cd /content/drive/MyDrive/colab/face-match && wget -O shivesh-hd.jpeg https://miro.medium.com/v2/resize:fit:2400/1*ohF2nXtuZx624xTKwlG9MQ.jpeg"
|
78 |
+
],
|
79 |
+
"metadata": {
|
80 |
+
"id": "eetSAvDhofhb"
|
81 |
+
},
|
82 |
+
"execution_count": null,
|
83 |
+
"outputs": []
|
84 |
+
},
|
85 |
+
{
|
86 |
+
"cell_type": "code",
|
87 |
+
"source": [
|
88 |
+
"!ls /content/drive/MyDrive/colab/face-match"
|
89 |
+
],
|
90 |
+
"metadata": {
|
91 |
+
"id": "4t3-O_5Bni0t"
|
92 |
+
},
|
93 |
+
"execution_count": null,
|
94 |
+
"outputs": []
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"source": [
|
99 |
+
"hd_train = os.path.join(dir, 'bhat-hd.jpg')\n",
|
100 |
+
"sd_train = os.path.join(dir, 'bhat-sd.jpg')\n",
|
101 |
+
"\n",
|
102 |
+
"hd_test = os.path.join(dir, 'bhat-test-hd.jpeg')\n",
|
103 |
+
"sd_test = os.path.join(dir, 'bhat-test-sd.jpeg')\n",
|
104 |
+
"\n",
|
105 |
+
"hd_unknown = os.path.join(dir, 'shivesh-hd.jpeg')"
|
106 |
+
],
|
107 |
+
"metadata": {
|
108 |
+
"id": "YayGIZgotAF5"
|
109 |
+
},
|
110 |
+
"execution_count": null,
|
111 |
+
"outputs": []
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"cell_type": "code",
|
115 |
+
"source": [
|
116 |
+
"result = DeepFace.verify(\n",
|
117 |
+
" img1_path = os.path.join(dir, 'shivesh-hd.jpeg'),\n",
|
118 |
+
" img2_path = os.path.join(dir, 'bhat-hd.jpg'),\n",
|
119 |
+
")\n",
|
120 |
+
"result"
|
121 |
+
],
|
122 |
+
"metadata": {
|
123 |
+
"id": "PhPwnGoWop1C"
|
124 |
+
},
|
125 |
+
"execution_count": null,
|
126 |
+
"outputs": []
|
127 |
+
},
|
128 |
+
{
|
129 |
+
"cell_type": "code",
|
130 |
+
"source": [
|
131 |
+
"result = DeepFace.verify(\n",
|
132 |
+
" img1_path = os.path.join(dir, 'bhat-test-hd.jpeg'),\n",
|
133 |
+
" img2_path = os.path.join(dir, 'bhat-test-hd.jpeg'),\n",
|
134 |
+
")\n",
|
135 |
+
"result"
|
136 |
+
],
|
137 |
+
"metadata": {
|
138 |
+
"id": "h6OwutnBlgKe"
|
139 |
+
},
|
140 |
+
"execution_count": null,
|
141 |
+
"outputs": []
|
142 |
+
},
|
143 |
+
{
|
144 |
+
"cell_type": "code",
|
145 |
+
"source": [
|
146 |
+
"!ls /content/drive/MyDrive/colab/face-match/bhat-test-sd.jpg"
|
147 |
+
],
|
148 |
+
"metadata": {
|
149 |
+
"id": "hXGLf_Mgn2gV"
|
150 |
+
},
|
151 |
+
"execution_count": null,
|
152 |
+
"outputs": []
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"cell_type": "code",
|
156 |
+
"source": [
|
157 |
+
"!pip3 install face_recognition"
|
158 |
+
],
|
159 |
+
"metadata": {
|
160 |
+
"id": "ALwbcczEn8wg"
|
161 |
+
},
|
162 |
+
"execution_count": null,
|
163 |
+
"outputs": []
|
164 |
+
},
|
165 |
+
{
|
166 |
+
"cell_type": "code",
|
167 |
+
"source": [],
|
168 |
+
"metadata": {
|
169 |
+
"id": "Wkn4Z44Rs-HY"
|
170 |
+
},
|
171 |
+
"execution_count": null,
|
172 |
+
"outputs": []
|
173 |
+
},
|
174 |
+
{
|
175 |
+
"cell_type": "code",
|
176 |
+
"source": [
|
177 |
+
"import face_recognition\n",
|
178 |
+
"image = face_recognition.load_image_file(\"your_file.jpg\")\n",
|
179 |
+
"face_locations = face_recognition.face_locations(image)"
|
180 |
+
],
|
181 |
+
"metadata": {
|
182 |
+
"id": "06ckkNXqsqfF"
|
183 |
+
},
|
184 |
+
"execution_count": null,
|
185 |
+
"outputs": []
|
186 |
+
}
|
187 |
+
]
|
188 |
+
}
|