EARLY36 commited on
Commit
8226662
·
verified ·
1 Parent(s): 09dbabe

create a real face verification system like StarGAN v2 to generate diverse image based on a human user that have similar feature vectors yet qualitatively look different ,face verification model based off a general implementation of facenet and deepface using a pre trained ConvNet inception model that encodes each input image into a 128-dimensional vector.system should use a database built on face images from the train subset of Fairface to pass facial verification system - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +331 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Face Verification V2
3
- emoji: 🦀
4
- colorFrom: red
5
  colorTo: green
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: face-verification-v2
3
+ emoji: 🐳
4
+ colorFrom: green
5
  colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,331 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Face Verification System | StarGAN v2 Inspired</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
12
+ }
13
+ .face-container {
14
+ perspective: 1000px;
15
+ }
16
+ .face-card {
17
+ transform-style: preserve-3d;
18
+ transition: all 0.5s ease;
19
+ }
20
+ .face-card:hover {
21
+ transform: rotateY(10deg);
22
+ }
23
+ .progress-ring {
24
+ transform: rotate(-90deg);
25
+ }
26
+ .progress-ring-circle {
27
+ stroke-dasharray: 314;
28
+ stroke-dashoffset: 314;
29
+ transition: stroke-dashoffset 0.5s ease;
30
+ }
31
+ .verification-success {
32
+ animation: pulse 2s infinite;
33
+ }
34
+ @keyframes pulse {
35
+ 0% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7); }
36
+ 70% { box-shadow: 0 0 0 10px rgba(72, 187, 120, 0); }
37
+ 100% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0); }
38
+ }
39
+ .verification-failed {
40
+ animation: pulse-red 2s infinite;
41
+ }
42
+ @keyframes pulse-red {
43
+ 0% { box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.7); }
44
+ 70% { box-shadow: 0 0 0 10px rgba(245, 101, 101, 0); }
45
+ 100% { box-shadow: 0 0 0 0 rgba(245, 101, 101, 0); }
46
+ }
47
+ .face-morph {
48
+ transition: all 0.5s ease;
49
+ }
50
+ .face-morph:hover {
51
+ filter: drop-shadow(0 0 10px rgba(118, 75, 162, 0.7));
52
+ }
53
+ </style>
54
+ </head>
55
+ <body class="gradient-bg min-h-screen text-white">
56
+ <div class="container mx-auto px-4 py-8">
57
+ <!-- Header -->
58
+ <header class="flex flex-col md:flex-row justify-between items-center mb-12">
59
+ <div class="flex items-center mb-4 md:mb-0">
60
+ <i class="fas fa-user-shield text-4xl mr-3"></i>
61
+ <h1 class="text-3xl font-bold">Face<span class="text-purple-300">VerifAI</span></h1>
62
+ </div>
63
+ <nav class="flex space-x-6">
64
+ <a href="#" class="hover:text-purple-300 transition">Home</a>
65
+ <a href="#" class="hover:text-purple-300 transition">API</a>
66
+ <a href="#" class="hover:text-purple-300 transition">Docs</a>
67
+ <a href="#" class="hover:text-purple-300 transition">Contact</a>
68
+ </nav>
69
+ </header>
70
+
71
+ <!-- Main Content -->
72
+ <main class="flex flex-col lg:flex-row gap-8">
73
+ <!-- Left Panel - Verification Interface -->
74
+ <div class="flex-1 bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-2xl p-6 shadow-xl">
75
+ <h2 class="text-2xl font-semibold mb-6 flex items-center">
76
+ <i class="fas fa-fingerprint mr-3"></i> Face Verification
77
+ </h2>
78
+
79
+ <!-- Camera Feed -->
80
+ <div class="face-container mb-8">
81
+ <div class="face-card bg-gray-800 rounded-xl overflow-hidden relative">
82
+ <div id="camera-feed" class="w-full h-64 md:h-80 bg-gray-900 flex items-center justify-center">
83
+ <div class="text-center">
84
+ <i class="fas fa-camera text-4xl mb-2 text-gray-500"></i>
85
+ <p class="text-gray-400">Camera feed will appear here</p>
86
+ </div>
87
+ </div>
88
+ <div class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-3">
89
+ <div class="flex justify-between items-center">
90
+ <span class="text-sm">Live face detection</span>
91
+ <div class="flex space-x-2">
92
+ <button class="bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded text-xs">
93
+ <i class="fas fa-camera-retro mr-1"></i> Capture
94
+ </button>
95
+ <button class="bg-blue-600 hover:bg-blue-700 px-3 py-1 rounded text-xs">
96
+ <i class="fas fa-video mr-1"></i> Start
97
+ </button>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+
104
+ <!-- Verification Controls -->
105
+ <div class="mb-8">
106
+ <h3 class="text-lg font-medium mb-4">Verification Options</h3>
107
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
108
+ <div class="bg-gray-800 bg-opacity-50 p-4 rounded-lg">
109
+ <div class="flex items-center mb-2">
110
+ <i class="fas fa-user-tag text-purple-400 mr-2"></i>
111
+ <span class="font-medium">1:1 Verification</span>
112
+ </div>
113
+ <p class="text-sm text-gray-300">Compare against a single reference image</p>
114
+ </div>
115
+ <div class="bg-gray-800 bg-opacity-50 p-4 rounded-lg">
116
+ <div class="flex items-center mb-2">
117
+ <i class="fas fa-users text-purple-400 mr-2"></i>
118
+ <span class="font-medium">1:N Identification</span>
119
+ </div>
120
+ <p class="text-sm text-gray-300">Search against a database of faces</p>
121
+ </div>
122
+ <div class="bg-gray-800 bg-opacity-50 p-4 rounded-lg">
123
+ <div class="flex items-center mb-2">
124
+ <i class="fas fa-random text-purple-400 mr-2"></i>
125
+ <span class="font-medium">Style Transfer</span>
126
+ </div>
127
+ <p class="text-sm text-gray-300">Generate diverse variations</p>
128
+ </div>
129
+ </div>
130
+ </div>
131
+
132
+ <!-- Verification Results -->
133
+ <div id="verification-results" class="hidden">
134
+ <h3 class="text-lg font-medium mb-4">Verification Results</h3>
135
+ <div class="bg-gray-800 bg-opacity-50 p-4 rounded-lg">
136
+ <div class="flex flex-col md:flex-row items-center justify-between">
137
+ <div class="flex items-center mb-4 md:mb-0">
138
+ <div class="relative mr-4">
139
+ <svg class="w-16 h-16">
140
+ <circle class="text-gray-700" stroke-width="8" stroke="currentColor" fill="transparent" r="24" cx="32" cy="32" />
141
+ <circle id="verification-progress" class="progress-ring-circle text-green-400" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="24" cx="32" cy="32" />
142
+ </svg>
143
+ <div class="absolute inset-0 flex items-center justify-center">
144
+ <span id="similarity-score" class="font-bold text-lg">0%</span>
145
+ </div>
146
+ </div>
147
+ <div>
148
+ <p class="font-medium">Similarity Score</p>
149
+ <p class="text-sm text-gray-300">Based on 128D feature vectors</p>
150
+ </div>
151
+ </div>
152
+ <div id="verification-status" class="px-4 py-2 rounded-full bg-gray-700 text-center">
153
+ <i class="fas fa-spinner fa-spin mr-2"></i> Processing
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <!-- Right Panel - StarGAN v2 Style Transfer -->
161
+ <div class="flex-1 bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-2xl p-6 shadow-xl">
162
+ <h2 class="text-2xl font-semibold mb-6 flex items-center">
163
+ <i class="fas fa-magic mr-3"></i> Style Transfer (StarGAN v2)
164
+ </h2>
165
+
166
+ <!-- Reference Image -->
167
+ <div class="mb-6">
168
+ <h3 class="text-lg font-medium mb-3">Reference Image</h3>
169
+ <div class="flex flex-col md:flex-row gap-4">
170
+ <div class="face-morph w-full md:w-1/2 h-48 bg-gray-800 rounded-lg flex items-center justify-center">
171
+ <div class="text-center">
172
+ <i class="fas fa-user-circle text-4xl mb-2 text-gray-500"></i>
173
+ <p class="text-gray-400">Upload reference</p>
174
+ </div>
175
+ </div>
176
+ <div class="w-full md:w-1/2">
177
+ <div class="mb-3">
178
+ <label class="block text-sm font-medium mb-1">Style Intensity</label>
179
+ <input type="range" min="0" max="100" value="50" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
180
+ </div>
181
+ <div class="mb-3">
182
+ <label class="block text-sm font-medium mb-1">Diversity Level</label>
183
+ <input type="range" min="0" max="100" value="30" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
184
+ </div>
185
+ <button class="w-full bg-purple-600 hover:bg-purple-700 py-2 rounded-lg font-medium">
186
+ <i class="fas fa-random mr-2"></i> Generate Variations
187
+ </button>
188
+ </div>
189
+ </div>
190
+ </div>
191
+
192
+ <!-- Generated Variations -->
193
+ <div>
194
+ <h3 class="text-lg font-medium mb-3">Generated Variations</h3>
195
+ <div class="grid grid-cols-2 md:grid-cols-3 gap-4">
196
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
197
+ <i class="fas fa-image text-2xl text-gray-500"></i>
198
+ </div>
199
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
200
+ <i class="fas fa-image text-2xl text-gray-500"></i>
201
+ </div>
202
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
203
+ <i class="fas fa-image text-2xl text-gray-500"></i>
204
+ </div>
205
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
206
+ <i class="fas fa-image text-2xl text-gray-500"></i>
207
+ </div>
208
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
209
+ <i class="fas fa-image text-2xl text-gray-500"></i>
210
+ </div>
211
+ <div class="face-morph bg-gray-800 rounded-lg h-32 flex items-center justify-center">
212
+ <i class="fas fa-image text-2xl text-gray-500"></i>
213
+ </div>
214
+ </div>
215
+ </div>
216
+
217
+ <!-- Feature Vector Visualization -->
218
+ <div class="mt-8">
219
+ <h3 class="text-lg font-medium mb-3">128D Feature Vector</h3>
220
+ <div class="bg-gray-800 bg-opacity-50 p-4 rounded-lg">
221
+ <div class="flex flex-wrap gap-1">
222
+ <!-- Generate 128 small boxes representing the feature vector -->
223
+ <script>
224
+ document.addEventListener('DOMContentLoaded', function() {
225
+ const container = document.createElement('div');
226
+ container.className = 'flex flex-wrap gap-1';
227
+
228
+ for (let i = 0; i < 128; i++) {
229
+ const box = document.createElement('div');
230
+ box.className = 'w-2 h-2 bg-purple-400 opacity-70';
231
+ box.style.opacity = Math.random() * 0.5 + 0.3;
232
+ container.appendChild(box);
233
+ }
234
+
235
+ document.querySelector('#verification-results').after(container);
236
+ });
237
+ </script>
238
+ </div>
239
+ <div class="mt-3 flex justify-between text-xs text-gray-400">
240
+ <span>Reference Vector</span>
241
+ <span>Input Vector</span>
242
+ </div>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </main>
247
+
248
+ <!-- System Info -->
249
+ <footer class="mt-12 text-center text-gray-300 text-sm">
250
+ <p class="mb-2">Powered by FaceNet architecture with Inception-ResNet-v1 backbone</p>
251
+ <p>Trained on FairFace dataset with triplet loss minimization</p>
252
+ <p class="mt-4">Euclidean distance threshold: 0.6 | Cosine similarity threshold: 0.8</p>
253
+ </footer>
254
+ </div>
255
+
256
+ <script>
257
+ // Simulate face verification process
258
+ document.addEventListener('DOMContentLoaded', function() {
259
+ // Show verification results section
260
+ const verificationResults = document.getElementById('verification-results');
261
+ verificationResults.classList.remove('hidden');
262
+
263
+ // Simulate verification progress
264
+ const progressCircle = document.getElementById('verification-progress');
265
+ const similarityScore = document.getElementById('similarity-score');
266
+ const verificationStatus = document.getElementById('verification-status');
267
+
268
+ let progress = 0;
269
+ const interval = setInterval(() => {
270
+ progress += 5;
271
+ const dashoffset = 314 - (314 * progress / 100);
272
+ progressCircle.style.strokeDashoffset = dashoffset;
273
+ similarityScore.textContent = `${progress}%`;
274
+
275
+ if (progress >= 85) {
276
+ clearInterval(interval);
277
+
278
+ // Randomly determine verification result for demo purposes
279
+ const isVerified = Math.random() > 0.3;
280
+
281
+ if (isVerified) {
282
+ verificationStatus.innerHTML = '<i class="fas fa-check-circle mr-2"></i> Verified';
283
+ verificationStatus.classList.remove('bg-gray-700');
284
+ verificationStatus.classList.add('verification-success', 'bg-green-600');
285
+ } else {
286
+ verificationStatus.innerHTML = '<i class="fas fa-times-circle mr-2"></i> Not Verified';
287
+ verificationStatus.classList.remove('bg-gray-700');
288
+ verificationStatus.classList.add('verification-failed', 'bg-red-600');
289
+ }
290
+ }
291
+ }, 200);
292
+
293
+ // Simulate camera feed with random face images
294
+ const cameraFeed = document.getElementById('camera-feed');
295
+ const faceImages = [
296
+ 'https://randomuser.me/api/portraits/women/43.jpg',
297
+ 'https://randomuser.me/api/portraits/men/32.jpg',
298
+ 'https://randomuser.me/api/portraits/women/65.jpg',
299
+ 'https://randomuser.me/api/portraits/men/76.jpg'
300
+ ];
301
+
302
+ setTimeout(() => {
303
+ cameraFeed.innerHTML = `<img src="${faceImages[Math.floor(Math.random() * faceImages.length)]}" class="w-full h-full object-cover" alt="Detected face">`;
304
+ }, 1500);
305
+
306
+ // Generate style transfer variations
307
+ const styleTransferBtn = document.querySelector('.bg-purple-600');
308
+ const generatedImages = document.querySelectorAll('.face-morph:not(.bg-gray-800)');
309
+
310
+ styleTransferBtn.addEventListener('click', function() {
311
+ // Replace placeholder icons with generated face images
312
+ document.querySelectorAll('.face-morph .fa-image').forEach((icon, index) => {
313
+ const parent = icon.parentElement;
314
+ parent.innerHTML = `<img src="https://randomuser.me/api/portraits/${index % 2 === 0 ? 'women' : 'men'}/${Math.floor(Math.random() * 100)}.jpg" class="w-full h-full object-cover rounded-lg" alt="Generated face">`;
315
+ parent.classList.add('bg-purple-900', 'bg-opacity-30');
316
+ });
317
+
318
+ // Show notification
319
+ const notification = document.createElement('div');
320
+ notification.className = 'fixed bottom-4 right-4 bg-purple-600 text-white px-4 py-2 rounded-lg shadow-lg flex items-center';
321
+ notification.innerHTML = '<i class="fas fa-check-circle mr-2"></i> 6 style variations generated';
322
+ document.body.appendChild(notification);
323
+
324
+ setTimeout(() => {
325
+ notification.remove();
326
+ }, 3000);
327
+ });
328
+ });
329
+ </script>
330
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EARLY36/face-verification-v2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
331
+ </html>