From 75f3e3c2699bfb209038507260ccf1d19e2c4c91 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 12 Mar 2021 18:24:34 -0500 Subject: [PATCH] distance based on minkowski space and limited euclidean space --- CHANGELOG.md | 3 +++ TODO.md | 24 +++++++++++++++++++++--- demo/embedding.js | 27 ++++++++++++++++++++------- src/human.ts | 11 ----------- wiki | 2 +- 5 files changed, 45 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 099c0932..d2ff4a93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ Repository: **** ## Changelog +### **HEAD -> main** 2021/03/12 mandic00@live.com + + ### **1.1.1** 2021/03/12 mandic00@live.com - switched face embedding to mobileface diff --git a/TODO.md b/TODO.md index c3a5817b..6e43a511 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,25 @@ # To-Do list for Human library -- Strong typing -- Automated testing -- Explore EfficientPose +## Big Ticket Items + +- Strong(er) typing +- Automated testing framework + +## Explore Models + +- EfficientPose +- ArcFace +- RetinaFace +- CenterFace + +## WiP Items + +- Embedding: + - Try average of flipped image + - Try with variable aspect ratio + +## Issues + +*N/A* diff --git a/demo/embedding.js b/demo/embedding.js index 228072e4..f9e50694 100644 --- a/demo/embedding.js +++ b/demo/embedding.js @@ -24,7 +24,7 @@ const userConfig = { const human = new Human(userConfig); // new instance of human -const samples = ['../assets/sample-me.jpg', '../assets/sample6.jpg', '../assets/sample1.jpg', '../assets/sample4.jpg', '../assets/sample5.jpg', '../assets/sample3.jpg', '../assets/sample2.jpg']; +// const samples = ['../assets/sample-me.jpg', '../assets/sample6.jpg', '../assets/sample1.jpg', '../assets/sample4.jpg', '../assets/sample5.jpg', '../assets/sample3.jpg', '../assets/sample2.jpg']; // const samples = ['../assets/sample-me.jpg', '../assets/sample6.jpg', '../assets/sample1.jpg', '../assets/sample4.jpg', '../assets/sample5.jpg', '../assets/sample3.jpg', '../assets/sample2.jpg', // '../private/me (1).jpg', '../private/me (2).jpg', '../private/me (3).jpg', '../private/me (4).jpg', '../private/me (5).jpg', '../private/me (6).jpg', '../private/me (7).jpg', '../private/me (8).jpg', // '../private/me (9).jpg', '../private/me (10).jpg', '../private/me (11).jpg', '../private/me (12).jpg', '../private/me (13).jpg']; @@ -57,7 +57,7 @@ async function analyze(face) { const canvases = document.getElementsByClassName('face'); for (const canvas of canvases) { // calculate simmilarity from selected face to current one in the loop - const res = human.simmilarity(face.embedding, all[canvas.tag.sample][canvas.tag.face].embedding); + const res = human.simmilarity(face.embedding, all[canvas.tag.sample][canvas.tag.face].embedding, 3); // draw the canvas and simmilarity score canvas.title = res; await human.tf.browser.toPixels(all[canvas.tag.sample][canvas.tag.face].tensor, canvas); @@ -98,8 +98,8 @@ async function faces(index, res) { } } -async function add(index) { - log('Add image:', samples[index]); +async function add(index, image) { + log('Add image:', index + 1, image); return new Promise((resolve) => { const img = new Image(100, 100); img.onload = () => { // must wait until image is loaded @@ -107,14 +107,27 @@ async function add(index) { document.getElementById('images').appendChild(img); // and finally we can add it resolve(true); }; - img.title = samples[index]; - img.src = samples[index]; + img.title = image; + img.src = encodeURI(image); }); } async function main() { await human.load(); - for (const i in samples) await add(i); // download and analyze all images + // enumerate all sample images in /assets + let res = await fetch('/assets'); + let dir = (res && res.ok) ? await res.json() : []; + let images = dir.filter((img) => (img.endsWith('.jpg') && img.includes('sample'))); + + // enumerate additional private test images in /private, not includded in git repository + res = await fetch('/private'); + dir = (res && res.ok) ? await res.json() : []; + images = images.concat(dir.filter((img) => (img.endsWith('.jpg')))); + + // download and analyze all images + log('Enumerated:', images.length, 'images'); + for (const i in images) await add(i, images[i]); + log('Ready'); } diff --git a/src/human.ts b/src/human.ts index 91d4bb87..2aa4c5c3 100644 --- a/src/human.ts +++ b/src/human.ts @@ -394,17 +394,6 @@ class Human { // combine results faceRes.push({ ...face, - /* - confidence: face.confidence, - faceConfidence: face.faceConfidence, - boxConfidence: face.boxConfidence, - box: face.box, - mesh: face.mesh, - boxRaw: face.boxRaw, - meshRaw: face.meshRaw, - offsetRaw: face.offsetRaw, - annotations: face.annotations, - */ age: ageRes.age, gender: genderRes.gender, genderConfidence: genderRes.confidence, diff --git a/wiki b/wiki index cef8c9cc..ac5d0125 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit cef8c9cc9f09f8709cd4bd1daff817a59df4b4d1 +Subproject commit ac5d01255f2f02de6b308b82976c5866c458f149