Face detection don't work on AWS Lambda due to node-canvas not working on node 8.10
See original GitHub issueHi there!
I am trying to get this up and running on AWS Lambda but are having trouble as it seem the ‘canvas’ package is broken on node 8.10. I am trying to get some face detection going.
https://github.com/Automattic/node-canvas/issues/1252#issuecomment-437598572
It looks like its kind of a pain to try and run any other version of node on AWS Lambda, so I started trying to use it without the canvas package. As you mention in the README and I also noticed that the faceapi.locateFaces() function also takes a Tensor4D class as input. I have never used Tensorflow and I am a little confused as how to turn a ArrayBuffer from axios into a correctly shaped Tensor4D object.
I am fetching a jpeg image using axios.
I found the tf.tensor4d function but not sure what shape and dtype it should be.
Do you have any idea?
My code so far:
const { data: imageBuffer } = await axios.get(url, {
responseType: 'arraybuffer'
})
const imageTensor = tf.tensor4d(imageBuffer, [?, ?, ? ,?])
const faces = await detector.locateFaces(imageTensor)
Error messages look similar to this one:
Error: Based on the provided shape, [1,2,3,4], and dtype float32, the tensor should have 24 values but has 68695
Any help is greatly appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Comments:24 (2 by maintainers)
Top GitHub Comments
Thanks!
Tried the get-pixels npm package and it works!
get-pixels return a 4 channel array all the time, even for jpegs 🤷 , so had to remove the alpha channel.
Now to the task of getting it up on Lambda without breaking their code size limit, wish me luck!
@bobmoff I have successfully deployed in Lambda using containers. But I’m facing one issue. I’m just doing
faceapi.detectSingleFace().withFaceLandmarks().withFaceDescriptor()
in lambda to detect single face and returning that output as a response via API Gateway. I can’t able to return without doingJSON.stringify(result)
and If I do stringify the result, that result not working in final comparison. I dont know what I’m doing wrong.update: I managed to fix it. And its working fine now.