Skip to content

Commit

Permalink
add human.draw.tensor method
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Mandic <[email protected]>
  • Loading branch information
vladmandic committed Oct 24, 2024
1 parent 2b0a2fe commit c1dc719
Show file tree
Hide file tree
Showing 26 changed files with 224 additions and 196 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

## Changelog

### **3.3.3** 2024/10/14 [email protected]
### **HEAD -> main** 2024/10/14 [email protected]

- add loaded property to model stats and mark models not loaded correctly.

### **origin/main** 2024/09/11 [email protected]
### **3.3.3** 2024/10/14 [email protected]

- add loaded property to model stats and mark models not loaded correctly.
- release build

### **3.3.2** 2024/09/11 [email protected]
Expand Down
2 changes: 1 addition & 1 deletion demo/facedetect/facedetect.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function addFace(face, source) {
e.preventDefault();
document.getElementById('description').innerHTML = canvas.title;
};
human.tf.browser.draw(face.tensor, canvas);
human.draw.tensor(face.tensor, canvas);
human.tf.dispose(face.tensor);
return canvas;
}
Expand Down
2 changes: 1 addition & 1 deletion demo/faceid/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions demo/faceid/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/faceid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function detectFace() {
if (!current?.face?.tensor || !current?.face?.embedding) return false;
console.log('face record:', current.face); // eslint-disable-line no-console
log(`detected face: ${current.face.gender} ${current.face.age || 0}y distance ${100 * (current.face.distance || 0)}cm/${Math.round(100 * (current.face.distance || 0) / 2.54)}in`);
await human.tf.browser.draw(current.face.tensor, dom.canvas);
await human.draw.tensor(current.face.tensor, dom.canvas);
if (await indexDb.count() === 0) {
log('face database is empty: nothing to compare face with');
document.body.style.background = 'black';
Expand Down
6 changes: 3 additions & 3 deletions demo/facematch/facematch.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function selectFaceCanvas(face) {
if (face.tensor) {
title('Sorting Faces by Similarity');
const c = document.getElementById('orig');
await human.tf.browser.draw(face.tensor, c);
await human.draw.tensor(face.tensor, c);
const arr = db.map((rec) => rec.embedding);
const res = await human.match.find(face.embedding, arr);
log('Match:', db[res.index].name);
Expand All @@ -97,7 +97,7 @@ async function selectFaceCanvas(face) {
canvas.tag.similarity = similarity;
// get best match
// draw the canvas
await human.tf.browser.draw(current.tensor, canvas);
await human.draw.tensor(current.tensor, canvas);
const ctx = canvas.getContext('2d');
ctx.font = 'small-caps 1rem "Lato"';
ctx.fillStyle = 'rgba(0, 0, 0, 1)';
Expand Down Expand Up @@ -144,7 +144,7 @@ async function addFaceCanvas(index, res, fileName) {
gender: ${Math.round(100 * res.face[i].genderScore)}% ${res.face[i].gender}
emotion: ${emotion}
`.replace(/ /g, ' ');
await human.tf.browser.draw(res.face[i].tensor, canvas);
await human.draw.tensor(res.face[i].tensor, canvas);
const ctx = canvas.getContext('2d');
if (!ctx) return;
ctx.font = 'small-caps 0.8rem "Lato"';
Expand Down
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async function calcSimmilarity(result) {
log('setting face compare baseline:', result.face[0]);
if (result.face[0].tensor) {
const c = document.getElementById('orig');
human.tf.browser.draw(result.face[0].tensor, c);
human.draw.tensor(result.face[0].tensor, c);
} else {
document.getElementById('compare-canvas').getContext('2d').drawImage(compare.original.canvas, 0, 0, 200, 200);
}
Expand Down
2 changes: 1 addition & 1 deletion demo/segmentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function main() {
return;
}
dom.fps.innerText = `fps: ${Math.round(10000 / (t1 - t0)) / 10}`; // mark performance
human.tf.browser.draw(rgba, dom.output); // draw raw output
human.draw.tensor(rgba, dom.output); // draw raw output
human.tf.dispose(rgba); // dispose tensors
ctxMerge.globalCompositeOperation = 'source-over';
ctxMerge.drawImage(dom.background, 0, 0); // draw original video to first stacked canvas
Expand Down
Loading

0 comments on commit c1dc719

Please sign in to comment.