Open zurek11 opened 6 years ago
And one more question. How can i save recogniser with added faces to database? Is there some way to save this variable there? (Because I want to use prediction more time and is non effective to train recognizer again and again with the same images).
Hi, if no faces are detected then the returned faceImages array is empty. In you case faceImage[0] is simply undefined I guess.
How to serialize a model to json and load it again is described in the readme:
Save a trained model to json file:
const fs = require('fs') const modelState = recognizer.serialize() fs.writeFileSync('model.json', JSON.stringify(modelState))
Load a trained model from json file:
const modelState = require('model.json') recognizer.load(modelState)
Simply serialize the model and store the json object or the stringified json in your db.
const modelState = require('model.json')
throws error: Cannot find module 'model.json' how can i install him? I was trying to install him as face-recognition so npm install model.json but console throw also error:
npm ERR! code E404
npm ERR! 404 Not Found: model.json@latest
model.json
is just a json file that you write the serialized state of the face recognizer to, as shown in the example above.
@zurek11
// file1.js
const fs = require('fs')
// init recognizer
const modelState = recognizer.serialize()
fs.writeFileSync('model.json', JSON.stringify(modelState))
// file2.js
const modelState = require('./model.json');
//init recognizer
recognizer.load(modelState)
Hi if i take a photo without any face is some way to handle this error with face detection? If so how can i handle this error? Because when i tried do that program returned this error: