mirror of https://github.com/vladmandic/human
Variable name changes, setting .rawCoords only if necessary
parent
95bbeb1146
commit
ad3dd30fa0
|
@ -17,7 +17,7 @@ class MediaPipeFaceMesh {
|
||||||
if (prediction.isDisposedInternal) continue; // guard against disposed tensors on long running operations such as pause in middle of processing
|
if (prediction.isDisposedInternal) continue; // guard against disposed tensors on long running operations such as pause in middle of processing
|
||||||
const mesh = prediction.coords ? prediction.coords.arraySync() : null;
|
const mesh = prediction.coords ? prediction.coords.arraySync() : null;
|
||||||
// AT: mesh_raw
|
// AT: mesh_raw
|
||||||
const mesh_raw = prediction.rawCoords;
|
const meshRaw = prediction.rawCoords;
|
||||||
const annotations = {};
|
const annotations = {};
|
||||||
if (mesh && mesh.length > 0) {
|
if (mesh && mesh.length > 0) {
|
||||||
for (let key = 0; key < coords.MESH_ANNOTATIONS.length; key++) {
|
for (let key = 0; key < coords.MESH_ANNOTATIONS.length; key++) {
|
||||||
|
@ -27,7 +27,7 @@ class MediaPipeFaceMesh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// AT: raw version of box, the same as the TFJS Facemesh output version (.boundingBox)
|
// AT: raw version of box, the same as the TFJS Facemesh output version (.boundingBox)
|
||||||
const box_raw = (config.face.mesh.requestRawData && prediction.box) ? {topLeft: prediction.box.startPoint, bottomRight: prediction.box.endPoint} : null;
|
const boxRaw = (config.face.mesh.returnRawData && prediction.box) ? {topLeft: prediction.box.startPoint, bottomRight: prediction.box.endPoint} : null;
|
||||||
|
|
||||||
const box = prediction.box ? [
|
const box = prediction.box ? [
|
||||||
Math.max(0, prediction.box.startPoint[0]),
|
Math.max(0, prediction.box.startPoint[0]),
|
||||||
|
@ -40,9 +40,9 @@ class MediaPipeFaceMesh {
|
||||||
confidence: prediction.confidence || 0,
|
confidence: prediction.confidence || 0,
|
||||||
box,
|
box,
|
||||||
mesh,
|
mesh,
|
||||||
// AT: box_raw, mesh_raw
|
// AT: boxRaw, meshRaw
|
||||||
box_raw,
|
boxRaw,
|
||||||
mesh_raw,
|
meshRaw,
|
||||||
annotations,
|
annotations,
|
||||||
image: prediction.image ? tf.clone(prediction.image) : null,
|
image: prediction.image ? tf.clone(prediction.image) : null,
|
||||||
});
|
});
|
||||||
|
|
|
@ -244,13 +244,13 @@ class Pipeline {
|
||||||
const transformedCoords = tf.tensor2d(transformedCoordsData);
|
const transformedCoords = tf.tensor2d(transformedCoordsData);
|
||||||
const prediction = {
|
const prediction = {
|
||||||
coords: transformedCoords,
|
coords: transformedCoords,
|
||||||
// AT: rawCoords
|
|
||||||
rawCoords: (config.face.mesh.requestRawData) ? rawCoords : null,
|
|
||||||
box: landmarksBox,
|
box: landmarksBox,
|
||||||
faceConfidence: confidenceVal,
|
faceConfidence: confidenceVal,
|
||||||
confidence: box.confidence,
|
confidence: box.confidence,
|
||||||
image: face,
|
image: face,
|
||||||
};
|
};
|
||||||
|
// AT: rawCoords
|
||||||
|
if (config.face.mesh.returnRawData) prediction.rawCoords = rawCoords;
|
||||||
// AT: preserve aspect ratio, pulled from Facemesh upstream
|
// AT: preserve aspect ratio, pulled from Facemesh upstream
|
||||||
this.storedBoxes[i] = { ...squarifiedLandmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal };
|
this.storedBoxes[i] = { ...squarifiedLandmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal };
|
||||||
// this.storedBoxes[i] = { ...landmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal };
|
// this.storedBoxes[i] = { ...landmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal };
|
||||||
|
|
|
@ -291,9 +291,9 @@ class Human {
|
||||||
confidence: face.confidence,
|
confidence: face.confidence,
|
||||||
box: face.box,
|
box: face.box,
|
||||||
mesh: face.mesh,
|
mesh: face.mesh,
|
||||||
// AT: box_raw, mesh_raw
|
// AT: boxRaw, meshRaw
|
||||||
box_raw: face.box_raw,
|
boxRaw: face.boxRaw,
|
||||||
mesh_raw: face.mesh_raw,
|
meshRaw: face.meshRaw,
|
||||||
annotations: face.annotations,
|
annotations: face.annotations,
|
||||||
age: ageRes.age,
|
age: ageRes.age,
|
||||||
gender: genderRes.gender,
|
gender: genderRes.gender,
|
||||||
|
|
Loading…
Reference in New Issue