node-facenet icon indicating copy to clipboard operation
node-facenet copied to clipboard

TypeError when running the codes

Open henrych4 opened this issue 8 years ago • 12 comments

I tried to run the library with nodejs and error occured.

Symbol.asyncIterator = Symbol.asyncIterator || Symbol.for('Symbol.asyncIterator'); ^ TypeError: Cannot assign to read only property 'asyncIterator' of function 'function Symbol() { [native code] }' at /Users/hhhung/Desktop/face_feature/node_modules/flash-store/bundles/flash-store.umd.js:101:26 at rimrafProxy__default (/Users/hhhung/Desktop/face_feature/node_modules/flash-store/bundles/flash-store.umd.js:40:68) at Object. (/Users/hhhung/Desktop/face_feature/node_modules/flash-store/bundles/flash-store.umd.js:43:2) at Module._compile (module.js:624:30) at Object.Module._extensions..js (module.js:635:10) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) at Module.require (module.js:568:17) at require (internal/module.js:11:18)

flash-store version: 0.1.2 How could I fix the problem? Thanks

henrych4 avatar Oct 17 '17 19:10 henrych4

Which node version did you use? Did you tired node v8? I believe it would work with problem under the latest version of node.

huan avatar Oct 18 '17 00:10 huan

I used node v8 at first and I changed to v7.0.0 but same error appears.

henrych4 avatar Oct 18 '17 02:10 henrych4

Could you please post your code which can reproduce this issue?

huan avatar Oct 18 '17 02:10 huan

import 'babel-polyfill'                                                                                                           
import { tmp } from './module'

tmp()

import { Facenet } from 'facenet'                                                                                                 

export async function tmp(){
    const facenet = new Facenet()
    const imageFile = `./test.png`
    const faceList = await facenet.align(imageFile)

    for (const face of faceList) {
        const embedding = await facenet.embedding(face)
        console.log('embedding: ', embedding)
    }   
}

Then I use babel to convert the two codes into es5.

henrych4 avatar Oct 18 '17 02:10 henrych4

Thank you for providing the re-produce code.

Could try to run them by babel-node and see if it will produce the same result?

huan avatar Oct 18 '17 02:10 huan

Errors occur when running by babel-node

For index.js(upper one): throw new Error("only one instance of babel-polyfill is allowed"); ^ Error: only one instance of babel-polyfill is allowed

For test.js(lower one): throw err; ^ SyntaxError: /Users/hhhung/Desktop/face_feature/test.js: await is a reserved word (6:17)


Update: Same result is produced after fixing the codes

henrych4 avatar Oct 18 '17 02:10 henrych4

Could you be able to run the demo from this repository?

It uses ts-node and should work without any problem.

Try run npm run demo

I have never tried babel, will try it when I have time.

huan avatar Oct 18 '17 10:10 huan

Thanks for your advices. Now I am able to run the codes and I have one more question. Is there any requirement for the input photo? I use some face photos as input but no face feature vector is returned.

henrych4 avatar Oct 18 '17 10:10 henrych4

There's two steps: alignment and embedding.

Which one did you tried, alignment or embedding?

I suggest you to read the source code to get to know the reason.

If you still has problem, please provide the reproduce procedure for your issue.

huan avatar Oct 18 '17 11:10 huan

Just tried embedding function with size 256x256, 128x128 and 96x96 face photos. Only the one with size 256x256 returns a feature vector.

henrych4 avatar Oct 18 '17 15:10 henrych4

Actually, I believe all the input image will be resized to 160x160 before feed to the neural network.

So the facenet.embedding() should return the 128 dim vector no matter than what size the image is.

You can check the source code, and let me know your result.

Thanks.

huan avatar Oct 20 '17 05:10 huan

I ran the demo with replacing the input, const imageFile = ${__dirname}/../tests/fixtures/two-faces.jpg with a 96x96 jpg. No result is returned. But when the photo is enlarged to higher dimension, like 256x256, an embedding vector is returned.

henrych4 avatar Oct 20 '17 06:10 henrych4