Closed nickbw2003 closed 6 years ago
Can you run my example code? if you could, could you find out which part different between the two code, could cause your problem?
If you could provide a minimum runnable code with reproduce steps, I might be able to have a look at it.
Sure. I've just added some example code to a fork of your project. Please see https://github.com/nickbw2003/node-facenet
You can start the sample via "npm run demo-buffer" Example code is located at "examples/demo_buffer.ts"
Many thanks
I remembered that the align()
should take a string parameter for the image file path?
According to your docs and code ist should also work by passing a ImageData object
According to your code: https://github.com/nickbw2003/node-facenet/blob/c336b26374ef293ccd6933463b18dec0c07ef5d0/examples/demo_buffer.ts#L8-L9
const imageBuffer = fs.readFileSync(`${__dirname}/../tests/fixtures/two-faces.jpg`);
const faces = await facenet.align({ data: new Uint8ClampedArray(imageBuffer), width: 640, height: 426 });
The problem is: your data
is not right.
A data
in ImageData is a raw array that stands for the col/row/RGB of the image, not the jpeg file data.
You have to use loadImage()
to decode the image file for you, and return the right imageData
.
Thank you. We are now using canvas to convert the image data - it's working as expected now.
Glad to know that.
Could you close this issue for now?
Hi there,
we are trying to use your project within a nodejs (v8) server project, but are currently struggling while aligning images by your facenet api which receives ImageData. Our process is as follows:
The point of error in our process is at step 3. We are using the align method like this:
private async getFaces(imageBuffer: Buffer): Promise<Face[]> { return await this.facenet.align({ data: new Uint8ClampedArray(imageBuffer), width: this.width, height: this.height }); }
And this is the error we are getting: [Nest] 40266 - 2018-3-7 14:07:46 [ExceptionsHandler] Traceback (most recent call last): File "/Users//dev/projects/my-project/server/node_modules/python-bridge/node_python_bridge.py", line 94, in
value = eval(_compile(data['code'], '', 'eval'), _locals)
File "", line 1, in
File "/Users//dev/projects/my-project/server/node_modules/facenet/dist/src/python3/facenet_bridge.py", line 195, in align
image = base64_to_image(image_base64, row, col, depth)
File "/Users//dev/projects/my-project/server/node_modules/facenet/dist/src/python3/facenet_bridge.py", line 43, in base64_to_image
image = image_array.reshape(row, col, depth)
TypeError: 'float' object cannot be interpreted as an integer
Error: Traceback (most recent call last): File "/Users//dev/projects/my-project/server/node_modules/python-bridge/node_python_bridge.py", line 94, in
value = eval(_compile(data['code'], '', 'eval'), _locals)
File "", line 1, in
File "/Users//dev/projects/my-project/server/node_modules/facenet/dist/src/python3/facenet_bridge.py", line 195, in align
image = base64_to_image(image_base64, row, col, depth)
File "/Users//dev/projects/my-project/server/node_modules/facenet/dist/src/python3/facenet_bridge.py", line 43, in base64_to_image
image = image_array.reshape(row, col, depth)
TypeError: 'float' object cannot be interpreted as an integer