Hi! I have a problem while loading the model with
faceapi.nets.faceLandmark68Net.loadFromUri('/public/models')
The model is available at the models directory. But an error arises while loading the model selected. In this case face_landmark_68_model-shard1 and face_landmark_68_model-weights-manifest.json are placed into the directory. But the following error appears:
Error: Based on the provided shape, [3,3,32,1], the tensor should have 288 values but has 64
Can someone help me please?
EDIT: This error appears if I my loading function is not async, if I make it async another error appears (regeneratorRuntime is not defined)
Thanks for your info

This is shown in the Inspector Network Tab. Apparently the GET request for the shard is not complete, but returns a 200 code. Does anyone know why is this possible?
Where do you host your application? Or does this also happen to be the case on your local dev environment (localhost)?
It happens in my local environment.
I solved the error of the shape by creating an extension to the shard1 file and in the json file setting the new name of the shard at the end with the extension I placed.
But still having the regeneratorRuntime and trying to solve it.
This means that the node version you are using doesn't seem to support async functions? Try updating nodejs to a more recent version or use babel if you have to use an older version.
Ok, my advances. I achieved to resolve it. And another problem arose 馃う鈥嶁檪. When using detectFaceLandmarks I am being returned a Promise. If I need to save those landmarks for the next videoFrame/Image how can I return that value outside the promise or is there any method to use faceapi "synchronously"?
Sidenote: if I use faceapi.detectFaceLandmarks(image); on full image (not just an image cropped to the face) am I doing something wrong? It returns unexpected values.
If I need to save those landmarks for the next videoFrame/Image how can I return that value outside the promise or is there any method to use faceapi "synchronously"?
I don't totally get what you are trying to achieve, but why don't you simply wait for the promise to resolve?
Sidenote: if I use faceapi.detectFaceLandmarks(image); on full image (not just an image cropped to the face) am I doing something wrong? It returns unexpected values.
Yeah that's not going to work out, since the face landmark net expects the cropped face image as input, which is obtained after face extraction based on the face box detected from the face detector.
async function detectLandmarks(image) {
const landmarks = await faceapi.detectFaceLandmarks(image);
return landmarks;
}
I don't totally get what you are trying to achieve, but why don't you simply wait for the promise to resolve?
That was my attempt. I am trying to wait the promise to resolve, but the method I pasted above, inside it (before return) is not a Promise, is resolved, but after return, where I use it is a Promise again and I can only use its values with the then structure (which I don't want)
faceapi.detectFaceLandmarks(image) returns a Promise and await faceapi.detectFaceLandmarks(image) resolves the Promise. Does that solve it?
Not at all. If I log the landmarks inside the method:
async function detectLandmarks(image) {
const landmarks = await faceapi.detectFaceLandmarks(image);
console.log(landmarks);
return landmarks;
}
It doesn't print a promise but the value of the landmarks. (Here is where I said Yay! I got it).
But when using the method like:
outsideLandmarks = detectLandmarks(outsideImage);
console.log(outsideLandmarks)
Which simply calls the method defined with the await inside it, prints a Promise.
Maybe I'm missing something or doing something wrong.
Tell me if I didn't explain myself.
Thanks for your patience
An async function always returns a Promise. Maybe I do not fully understand, what's the issue you are facing with the function returning a Promise?
state = initialState;
computedLandmarks = computeLandmarks(detectLandmarks(image));
updateState depending on the landmark computation;
This is what I'm trying to do more or less. With the promises what I have to do is:
state = initialState;
computedLandmarks = detectLandmarks(image)
.then((landmarks)=>
computation = computeLandmarks(landmarks)
return computation);
updateState depending on the landmark computation;
I cant do this because I cant extract the computation from the promise. So I cant update the state
I managed to solve it serving model files from a cdn
Use https://gitcdn.xyz/repo/justadudewhohacks/face-api.js/master/weights/ as MODEL_URL
This is a serious problem for using parcel to do development with this library:
https://github.com/elwin013/parcel-plugin-static-files-copy/issues/37
Most helpful comment
This is a serious problem for using
parcelto do development with this library:https://github.com/elwin013/parcel-plugin-static-files-copy/issues/37
https://github.com/parcel-bundler/parcel/issues/1098
https://github.com/tensorflow/tfjs/issues/924