Last active
May 11, 2023 06:29
-
-
Save irealva/6d6b7cacda0bba2f41117142105cc6dd to your computer and use it in GitHub Desktop.
Gist for Move Mirror blog post: cosine distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Great npm package for computing cosine similarity | |
const similarity = require('compute-cosine-similarity'); | |
// Cosine similarity as a distance function. The lower the number, the closer // the match | |
// poseVector1 and poseVector2 are a L2 normalized 34-float vectors (17 keypoints each | |
// with an x and y. 17 * 2 = 34) | |
function cosineDistanceMatching(poseVector1, poseVector2) { | |
let cosineSimilarity = similarity(poseVector1, poseVector2); | |
let distance = 2 * (1 - cosineSimilarity); | |
return Math.sqrt(distance); | |
} |
thanks for that! fixed it
We used each person’s bounding box coordinates to crop and scale each image (and corresponding keypoint coordinates) to a consistent size.
how tom crop and scale? why height == weight?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 32 at the end of the second comment should be 34.