mirror of https://github.com/vladmandic/human
updated embedding function
parent
4b4df95652
commit
1956559f38
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"bytes": 1783941,
|
||||
"bytes": 1783928,
|
||||
"imports": []
|
||||
}
|
||||
},
|
||||
|
@ -38,14 +38,14 @@
|
|||
"dist/demo-browser-index.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2678157
|
||||
"bytes": 2678104
|
||||
},
|
||||
"dist/demo-browser-index.js": {
|
||||
"imports": [],
|
||||
"exports": [],
|
||||
"inputs": {
|
||||
"dist/human.esm.js": {
|
||||
"bytesInOutput": 1776696
|
||||
"bytesInOutput": 1776683
|
||||
},
|
||||
"demo/draw.js": {
|
||||
"bytesInOutput": 7668
|
||||
|
@ -60,7 +60,7 @@
|
|||
"bytesInOutput": 19407
|
||||
}
|
||||
},
|
||||
"bytes": 1830431
|
||||
"bytes": 1830418
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -137,7 +137,7 @@
|
|||
]
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytes": 2107,
|
||||
"bytes": 2066,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.esm.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2582747
|
||||
"bytes": 2582694
|
||||
},
|
||||
"dist/human.esm.js": {
|
||||
"imports": [],
|
||||
|
@ -396,7 +396,7 @@
|
|||
"bytesInOutput": 1790
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytesInOutput": 1360
|
||||
"bytesInOutput": 1347
|
||||
},
|
||||
"src/body/modelBase.js": {
|
||||
"bytesInOutput": 612
|
||||
|
@ -471,7 +471,7 @@
|
|||
"bytesInOutput": 22
|
||||
}
|
||||
},
|
||||
"bytes": 1783941
|
||||
"bytes": 1783928
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -137,7 +137,7 @@
|
|||
]
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytes": 2107,
|
||||
"bytes": 2066,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 2549709
|
||||
"bytes": 2549656
|
||||
},
|
||||
"dist/human.js": {
|
||||
"imports": [],
|
||||
|
@ -394,7 +394,7 @@
|
|||
"bytesInOutput": 1769
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytesInOutput": 1338
|
||||
"bytesInOutput": 1325
|
||||
},
|
||||
"src/body/modelBase.js": {
|
||||
"bytesInOutput": 612
|
||||
|
@ -469,7 +469,7 @@
|
|||
"bytesInOutput": 22
|
||||
}
|
||||
},
|
||||
"bytes": 1783252
|
||||
"bytes": 1783239
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@
|
|||
"imports": []
|
||||
},
|
||||
"package.json": {
|
||||
"bytes": 2322,
|
||||
"bytes": 2323,
|
||||
"imports": []
|
||||
},
|
||||
"src/age/age.js": {
|
||||
|
@ -137,7 +137,7 @@
|
|||
]
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytes": 2107,
|
||||
"bytes": 2066,
|
||||
"imports": [
|
||||
{
|
||||
"path": "dist/tfjs.esm.js"
|
||||
|
@ -357,7 +357,7 @@
|
|||
"dist/human.node-gpu.js.map": {
|
||||
"imports": [],
|
||||
"inputs": {},
|
||||
"bytes": 685707
|
||||
"bytes": 685654
|
||||
},
|
||||
"dist/human.node-gpu.js": {
|
||||
"imports": [],
|
||||
|
@ -397,7 +397,7 @@
|
|||
"bytesInOutput": 1861
|
||||
},
|
||||
"src/embedding/embedding.js": {
|
||||
"bytesInOutput": 1411
|
||||
"bytesInOutput": 1398
|
||||
},
|
||||
"src/body/modelBase.js": {
|
||||
"bytesInOutput": 655
|
||||
|
@ -466,10 +466,10 @@
|
|||
"bytesInOutput": 1368
|
||||
},
|
||||
"package.json": {
|
||||
"bytesInOutput": 20
|
||||
"bytesInOutput": 21
|
||||
}
|
||||
},
|
||||
"bytes": 249919
|
||||
"bytes": 249907
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,14 +17,11 @@ async function load(config) {
|
|||
|
||||
function simmilarity(embedding1, embedding2) {
|
||||
if (embedding1?.length !== embedding2?.length) return 0;
|
||||
// euclidean distance
|
||||
const distance = 10 * Math.sqrt(
|
||||
embedding1
|
||||
.map((val, i) => (val - embedding2[i]))
|
||||
.reduce((dist, diff) => dist + (diff ** 2), 0),
|
||||
);
|
||||
const confidence = 2 * (0.5 - distance); // double confidence output for bigger differences and round to three decimals
|
||||
return Math.trunc(1000 * confidence) / 1000;
|
||||
// general minkowski distance
|
||||
// euclidean distance is limited case where order is 2
|
||||
const order = 2;
|
||||
const distance = 10.0 * ((embedding1.map((val, i) => (val - embedding2[i])).reduce((dist, diff) => dist + (diff ** order), 0) ** (1 / order)));
|
||||
return (Math.trunc(1000 * (1 - distance)) / 1000);
|
||||
}
|
||||
|
||||
async function predict(image, config) {
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit 64516d31f04a2e915c22c0ac2fe9312392d0d9c3
|
||||
Subproject commit 6a8806585c67dc6709ef244f86ffdd980404b66a
|
Loading…
Reference in New Issue